Join us

Introduction to Docker

1_jFEUrbW5VbWlLfeKwu3jFw.jpeg

If you are in the IT field, there is no way that you haven’t heard of Docker. Docker is the most popular DevOPS Tool in the present world. Docker is the containerization tool. It is used in containerization of Software.

What is containerization of Software?

Let’s first talk about containers, you must be aware about containers and what they are used for. Containers are used to carry goods across oceans or for long distances. Similarly in the software world when we want to carry our software to some other machine, we use containerization. we contcontainerize our software in the container and then load it to other machine.

Why Use containerization?

Generally the big software has a lot of dependencies to run. You may have developed software on your machine with configuration such as linux machine with php version of 7 and mysql version of 5. when you give software to some other machine, that machine may contain windows OS, php version of 9 and mysql version of 6. So your software will not work on that machine. you must have to do a lot of installations before running Software.

This problem is solved by containerization. What you can do is containerize your code along with all the required tools for it in one container and load that container to another machine. you can containerize your code with Linux OS, PHP version 7 and Mysql version 6 and load it on any machine and can run directly.

Where it is mostly used?

Docker is the one tool that can make your life easy with regards to deployment or testing the software. Whenever you want to deploy any software that you developed on your machine to a production machine, it can give lots of dependency issues as well as version issues. So, here Docker is the best choice for you. You can containerize your Code with All the respective dependencies and make it ready for deplyment. Thus your deployment process will be smooth smooth like butter.

It may happen that you develop software and pass it to the testing team and they say it is not working on their machine or some particular functionality is not working. It may happen due to a mismatch of versions of dependencies. This is where Docker comes into the picture. You can containerize your Code with All the respective dependencies and then pass it to the testing team.

Images on DockerHub

What is Docker Hub?

Docker Hub is just like the Port where we have to store containers. On Docker Hub there are a lot of containers available with some configurations done on them.we can call them as readymade containers. You can find containers with Ubuntu installed, Php containers with whatever version you want, mysql containers with whatever version you want etc. You can find docker hub on the following url: https://hub.docker.com/.

What is Docker Image?

Docker Images are just like a template to start with. they are like an initial that your container can start with. If you have a particular image on your machine, then you can make multiple copies of that image called a container and can customize those containers according to your need. It is just like creating multiple objects of a particular class, here class can refer to Docker Image.

let’s understand by example, you can have an image of ubuntu:20.0.4 on your machine. With this machine you can create containers such as PHP+MYSQL on Ubuntu, Django on Ubuntu, Node JS on Ubuntu etc.

Steps to Install Docker Desktop on Windows

  1. Download the Docker Desktop Installer.exe from Docker Hub.
  2. Double-click Docker Desktop Installer.exe to run the installer.
  3. When prompted, ensure the Enable Hyper-V Windows Features or the Install required Windows components for WSL 2 option is selected on the Configuration page.
  4. Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
  5. When the installation is successful, click Close to complete the installation process.
  6. Now you can start Docker Desktop by searching it from app search in windows.

Steps to Install Docker on Ubuntu

  1. Go to https://download.docker.com/linux/ubuntu/dists/, choose your Ubuntu version, then browse to pool/stable/, choose amd64, armhf, arm64, or s390x, and download the .deb file for the Docker Engine version you want to install
  2. Install Docker Engine, changing the path below to the path where you downloaded the Docker package.
  • $ sudo dpkg -i /path/to/package.deb
  1. The Docker daemon starts automatically.
  2. Verify that Docker Engine is installed correctly by running the hello-world image.
  • $ sudo docker run hello-world
  1. This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.

Popular Docker Commands

check the Docker version

$ docker version

get help with docker command

$ docker <command> --help

list all the available docker images on your machine

$ docker images

pull particular Docker Image from Docker Hub

$ docker pull <image_name>

eg: docker pull ubuntu

remove particular image from local machine

$ docker rmi <image_name>

eg: docker rmi ubuntu

list all the containers available on local machine

$ docker container ls -a

start a particular container

$ docker start <container_id>

eg: “docker start 6f8602b79294” you can get container id with command$ docker container ls -a

to stop a particular container

$ docker stop <container_id>

eg: docker stop 6f8602b79294

to pause a particular container

docker pause <container_id>

eg: docker pause 6f8602b79294

to resume paused container

docker unpause <container_id>

eg: docker unpause 6f8602b79294

to kill running container

docker kill <container_id>

eg: docker kill 6f8602b79294

to remove the container

docker rm <container_id>

eg: docker rm 6f8602b79294


Only registered users can post comments. Please, login or signup.

Start blogging about your favorite technologies, reach more readers and earn rewards!

Join other developers and claim your FAUN account now!

Avatar

Dilip Joshi

sggs

@djs2082
Passionate Engineer hungry of creating creative things with new tools and technologies.
User Popularity
29

Influence

3k

Total Hits

1

Posts