Getting started with docker
14 February 2019
.
Docker: the containerization you can’t seem to escape. Docker can allow you great power and flexibility to make your application light weight portable. But wait, what exactly is docker? And how can you get started with Docker? Let’s set out to figure those things out.
Our favorite guides
What is it?
Docker allows you to package and ship your application in a standardized and consistent format. Get the shipping references yet? Running an application with docker allows you to start it with a single command and that command can be consistent for your local and production environments.
Install
If you’re on a mac you can head over to the Docker Install Docker Desktop For Mac page as that is the easiest way to get Docker setup on your computer. If you’ve followed the steps successfully and have it up and running, inputting:
into your terminal should give you an output something like this:
If you’re running linux, depending on the flavor you’ll have to run a few commands to get it installed successfully. Each flavor’s installation insturctions can be found on the Docker website:
Ship
Now that you have docker up and running you can download an image and get an
example application running. We’re going to get an application running that
outputs “hello world”, because programming 😏. Docker can run certain images,
and for our case we’re going to run a helloworld
image that can be found
here. In our terminal let’s run:
Assuming you haven’t run this image before, you should see some output where Docker is telling you that it is downloading this image locally since we’ve never run it before:
Once it finishes downloading it will just hang in your terminal, which means it downloaded successfully and is running. Let’s break down the command we ran to start:
We’re telling docker to bind our machine (the docker host) at port 8080 to the docker
container at port 80 using a TCP connection. (🤔 Read more).
In short, we’re telling the application to run on our computer at port 8080.
Now if we go to our browser and go to the address: http://localhost:8080
we should
see our application!
Hungry for more docker content? Check out Awesome docker for all of the docker resources you could ever dream of!