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 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.Collaboartors 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 contianers 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 excuted, 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](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#general-guidelines-and-recommendations)

## Run your very first docker image
For this excercise 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](https://medium.com/@claudiopro/first-steps-with-docker-95bd08090625).

To begin let us execute the command below to run the Nginx image:

$ docker run nginx:lastest echo “Container Executed”
Unable to find image ‘nginx:latest’ locally
latest: Pulling from library/nginx
ff3d52d8f55f: Pulling fs layer
226f4ec56ba3: Pulling fs layer
ff3d52d8f55f: Downloading 245 kB/23.2ff3d52d8f55f: Downloading 490.7 kB/23.28 MB
226f4ec56ba3: Downloading 458 kB/21.5ff3d52d8f55f: Downloading 736.5 kB/23.2ff3d52d8f55f: Pull complete
226f4ec56ba3: Pull complete
53d7dd52b97d: Pull complete
Digest: sha256:41ad9967ea448d7c2b203c699b429abe1ed5af331cd92533900c6d77490e0268
Status: Downloaded newer image for nginx:latest
Container terminated
`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 
 $ docker run -it nginx:latest bash
root@a6e49c782178:/# ls
bin dev home lib32 libx32 mnt proc run srv tmp var
boot etc lib lib64 media opt root sbin sys usr
I Will be covering creating and publishing a docker image in the next tutorial.