Docker Introduction

Posted on Posted in Architect, Java

What is Docker? 

“Docker is the world’s leading software container platform. Developers use Docker to eliminate “works on my machine” problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density. Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely and with confidence for both Linux and Windows Server apps.”

Basically, it is a container for your applications, you setup your docker with all the prerequisites for your web-applications and then you deploy the whole container. Say for example, you web-application needs to connect to mysql, or a messaging queue(e.g kafka), you setup docker once, and that same container you publish in different environments.

It will be clearer once you we dive in to the details:

Setting up docker.

1.) You need to install docker on your machine, download the necessary installer:

For windows home:

Note: Docker is different if you are just using windows home, windows pro enables you to virtualization hence docker is can run smoothly, for those os that does not support virtualization use docker-toolbox

2.) Create an account in dockerhub,

docker hub is like dockers repository, this is where finished images/repository are published, and are just pulled on the fly to your container.

For example, if you want mysql in your container you would just pull from this one: dockerhub mysql and then tweak it to your configuration.

Once installed, run docker/docker-toolbox and you should be able to see this screen, note the ip:

This ip acts as your localhost or, so any applications running are accessible via this ip

3.) Login into docker hub in your docker application via running the below:

docker login 

I have mine already logged in, but you should see something similar.

4.) Pull hello-world image via this command, if you are wondering where we got hello-world, it is located in docker-hub tutum/hello-world. We are just pulling a image from docker-hub.

docker pull tutum/hello-world

4.) Run the actual image, using this command:

docker run -d -p 8080:80 –name first_example tutum/hello-world

The flags are explained below

  • run – docker run command
  • -d – run in background
  • -p – publish to port 80, (THIS IS VERY IMPORTANT, since we are running in our docker, we need to be able publish this outside our container otherwise we won’t be able to hit the application from outside docker.
  • –name : pass the name of container
  • tutum/hello-world – lastly, the image we want to run

Use this command to see the running instances : docker ps

notice that it says ports: -> 80 tcp, this is the port we exposed to so it should be reachable now via:

*Yes that is the docker ip! if we don’t specify -p flag when running we won’t be able to hit this in our local browsers.

Congrats you have now started your own docker container! Check out this page for command references, which are pretty straight-forward:

Leave a Reply