Docker — adoption in Organisations

Megha Pandey
Viithiisys
Published in
5 min readSep 25, 2017

Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run virtually anywhere on any type of server.

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 applications 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, Windows Server, and Linux-on-mainframe applications.

Docker Elements

  1. Docker Containers: Docker containers wrap up a piece of software in a complete file system that contains everything it needs to run: code, runtime, system tools, system libraries — anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.
  2. Docker Images: Basically snapshot of a container which contains base operating systems and all iterative changes made. An image is an ordered collection of root file system changes and the corresponding execution parameters for use within a container runtime. Images are read-only.
  3. Docker Files: Docker files are scripts that automates the build process for creating an image. Docker can build images automatically by reading the instructions from a Docker file. A Docker file is a text document that contains all the commands a user could call on the command line to assemble an image.

Working with Docker

Docker Installation on Ubuntu 16.04 :

The Docker installation package , available in Ubuntu 16.04 repository may not be the latest version. To get the latest version, install Docker from the official Docker repository.

Add the GPG key for the official Docker repository to the system:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add Docker repository to APT resources

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Next, Update Database:

$ sudo apt-get update
$ apt-cache policy docker-ce

Finally, install & check Docker status:

$ sudo apt-get install -y docker-ce
$ sudo systemctl status docker

Getting started with Docker :

  • Pulling a Docker image (Ubuntu) from Docker Hub

Note : By default, running the docker command requires root privileges — that is, you have to prefix the command with sudo

$ sudo docker pull ubuntu 
$ sudo docker run ubuntu

This will pull the image , run the container and will immediately exit it. We can check this with below command:

$ sudo docker ps -a

To keep the container running, run following command:

$ sudo docker run -it -d ubuntu
  • Login to the running container and make the desired changes

Lets install node.js 6.x

$ sudo docker exec -it b7eb2c574399 (container ID) bash
root@3ac72397f612:/#apt-get update
root@3ac72397f612:/#apt-get install curl
root@3ac72397f612:/#curl -sL https://deb.nodesource.com/setup_6.x | bash -
root@3ac72397f612:/#apt-get install -y nodejs
root@3ac72397f612:/#nodejs -v
root@3ac72397f612:/# exit (exit from the container)

Exit the container using ‘exit’ command

Now, Create your user account in Docker Hub : https://hub.docker.com/

Next, we have to commit the container changes into the local ubuntu image. For that first of all stop the running container:

$ sudo docker stop b7eb2c574399 (Container ID)
$ sudo docker commit b7eb2c574399 (Container ID) docker hub username/image-name
i.e
$ sudo docker commit b7eb2c574399 meghapandey/nodejs

Run the container:

sudo docker run -it -d meghapandey/nodejs (modified image name) bash

Now check the running containers and Log in into the modified container ID to check the nodejs version :

$ sudo docker ps -a
$ sudo docker exec -it db07f623e67b bash
root@db07f623e67b:/#nodejs -v
root@db07f623e67b:/#exit
  • Pushing the Image to Docker Hub :

Firstly, Login to the Docker Hub

$ sudo docker login --username=your username
Password:
Login Succeeded

Then push the modified — image to the docker hub

$ sudo docker push username/image-name

Your image is now pushed to Docker Hub. You can find the same in your DockerHub Repository

You will find the image you pushed to the Docker Hub. These images are public and are accessible by anyone.

  • Pulling the image from Client Machine :

Install Docker on the client Machine and pull the image from Docker Hub

$ sudo docker pull username/image-name

Run the downloaded image as mentioned earlier :

Nodejs version v6.11.3 is already installed in the image we pulled.

Thanks for Reading ! Hope you have enjoyed.If you found this article helpful, some claps would mean a lot!

For more updates Stay tuned :)

--

--