Hello!
I've written this brief blog to introduce Docker to some developers in my small community of fellow developers.
What is Docker and Why Do You Need it?
If you're a software developer, you may have heard of Docker before, (I'm pretty sure you did already!). But what is Docker, exactly, and why is it such an important technology to learn?
In this blog, we'll explore the basics of Docker and show you how to get started using it. (Obviously theres a lot of existing youtube / blog that tackles what / why / how Docker is, but I'm glad if you stumbled upon this post and somehow this helped you get started with Docker)
At its core, Docker is a tool for containerizing applications. That might sound a bit technical, but it just means that Docker allows you to package up **all the code, dependencies, and configuration needed to run an application into a **single container. This container can then be run on any machine that has Docker installed, regardless of the underlying operating system or hardware.
Why Docker?
Consistent Environments:
With Docker, you can be sure that the environment in which your application runs is consistent, no matter where it's deployed. This makes it much easier to manage and troubleshoot applications, since you don't have to worry about differences in the underlying infrastructure / os. (Yup, this solves the "But It works on my machine" issue)
Portability:
Since Docker containers can be run on any machine with Docker installed, they can be easily moved between development, testing, and production environments. This makes it much easier to develop and test applications locally before deploying them to production.
Scalability:
Docker makes it easy to scale applications horizontally by running multiple containers in parallel. This allows you to handle more traffic or workload without having to invest in expensive hardware or infrastructure.
How to get started with Docker
If you're new to Docker, getting started can seem a bit daunting. But don't worry - Docker has a great getting started guide that walks you through the process step by step.
Here are the basic steps you'll need to follow:
Install Docker:
The first step is to install Docker on your machine. Docker has installation instructions for all major operating systems on their website. See HERE
Build Your First Image:
Once you have Docker installed, you can build your first Docker image. An image is basically a snapshot of your application and its dependencies at a particular point in time. To build an image, you'll need to create a Dockerfile, which is a script that tells Docker how to build the image. Once you have a Dockerfile, you can run the docker build command to build the image.
Run Your Container:
Once you have an image, you can run it in a container. A container is basically an instance of an image that's running on your machine. To run a container, you'll use the docker run command, which tells Docker to start a new container from the specified image.
And that's it! Of course, there's a lot more to Docker than just these basic steps, but they should be enough to get you started.
Top comments (2)
"This container can then be run on any machine that has Docker installed, regardless of the underlying operating system "
That's not really true though if you've used docker on windows. Can't run those images on linux. There's no abstraction or vm. Only a hyperviser that sand boxes you from the host OS.
Your windows docker file commands are just powershell commands, it's annoyingly tied to the host os. I don't understand why there isn't more abstraction to this. Really ruins the whole thing for me.
I guess I have generalized it much on that sentence and you are correct that there are some limitations to running Docker on Windows, especially when it comes to running images that were built specifically for Linux-based environments, thanks for pointing that out!