Introduction to Docker-Part1

Almost everyone of us has  heard of Docker . Actually Docker revolution started in mid 2013 and today more than 4 million Apps use Docker. Docker has revolutionised Devops movement.

Docker is  a tool/software that helps in creating containers consisting of apps and dependencies. Container is similar to what we see in real world transportation.

Containers pack apps along with dependencies together and help them deploy or transfer across development environments or developers. New team mates can easily get started with projects once they have the Docker installed on there system

The heart of Docker lies in the DockerFile.  It is simple text file with commands, ports and base image list.  It has a basic configuration for running app.

Example docker file:

Screen Shot 2018-01-01 at 7.59.38 PM 1

For building a docker image we need to run the following command at the root of the project where DockerFile resides

docker build -t mongotest .

The above command builds an image and tags it to image name mongotest

-t flag is used for tagging to image file name

Short interpretation of the above Docker File:

From mongo command pulls the image from Docker hub repository.

CMD[“mongod”] command is the default command that runs when our container is up

In above docker file we are exposing ports 27017 and 28017.

While  running above created image we need to expose these ports to the host system.

Docker is run by the following command:

docker run -p 27017:27017 -p 28017:28017 mongotest

Important note for beginners:

Dockerfile should have D in caps and should have no extension

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s