Understanding the basics of Docker

Published Jun 22, 2017Last updated Jul 07, 2017

Understanding the basics of Docker

Collaboration between developers has become easier with Docker, it eliminates repetitive tasks while setting up and configuring development environments.
In this post I will be explaining the fundamentals of docker and basic usage.

Docker
Docker is a platform to build, ship and run any application as a light weight isolated container. The container contains everything required to run a piece of software. Collaborators on a software don’t need worry about the complexities faced when setting up.The complexity is pushed into containers that are easy to build, deploy and run.

Containers , Images and Dockerfile
It is quite often to mistake the definitions of images and containers when using docker.An image in docker is an executable package that contains everything needed to run a software. While a container is a runtime instance of an image. The image can contain codes, config and environment variables. Once an image is executed, a light weight isolated container is created.
Docker can build images automatically by reading instructions from a file which is a dockerfile. Think of a dockerfile as a list of instructions needed to create an image.You can read more about dockerfile here

Run your very first docker image

For this exercise we are going to be working with an official image before we go on to create ours. Docker has two types of images, official and contributed you can read more about docker images here.
To begin let us execute the command below to run the Nginx image:

docker run — command to run an image, docker looks for nginx:latest image locally and if it does not exist it pulls the image. So next time if I try to run this image again it will only print out Container Executed
We can keeps containers alive without them terminated after an image has been downloaded by adding the -it flag. This automatically takes us to the root of the container