In this blog we’ll try to understand one of the most popular tools used to over the internet i.e. Docker. It makes deploying applications extremely simple. containerize and deploy applications We will try to look at the things that make Docker so special and learn how you can using Docker & Docker Hub using just a few steps. build, deploy, and fetch applications What is Docker? It is a tool used to . create, deploy and run applications by using containers allows developers to . Containers package up an application with all the parts it needs are and Containers isolated from one another bundle their own software, libraries and configuration file. 1. Docker Containers: Docker Containers contain . binaries, libraries and configuration files along with the application itself They don’t contain a guest OS for each container and rely on the underlying OS kernel, which makes the containers . lightweight Containers in the same host OS and share resources with other containers provide OS level process isolation. 2. Virtual Machines: Virtual Machines (VMs) run on , which along with its own operating system. Hypervisors allow multiple Virtual Machines to run on a single Machine Each VM has its own copy of an operating system along with the application and necessary binaries, which makes it significantly . larger and it requires more resources They provide and Hardware-level process isolation are slow to boot. Terminologies Important in Docker : 1. Docker Image: It is a file, comprised of multiple layers, used to execute code in a Docker container. They are a set of instructions used to create docker containers. 2. Docker Container: It is a . runtime instance of an image Allows developers to package application with all parts needed such as libraries and other dependencies. 3. Docker file: It is a text document that contains necessary commands which on execution helps assemble a Docker Image. Docker image is created using a Docker file. 4. Docker Engine: The software that hosts the containers is named . Docker Engine Docker Engine is a client-server based application. It consists of 3 main components : : It is on the Docker. It is referred to as a Server responsible for creating and managing Docker images, containers, networks and volumes daemon process. : It specifies how the applications can interact with the Server, and instructs it what to do. REST API : The Client is a docker command-line interface (CLI), that allows us to interact with Docker using the commands. Client docker 5. Docker Hub: Docker Hub is the where you can find other Docker Images that are available for use. official online repository It makes it easy to with others. find, manage and share container images Installing Docker on Ubuntu 1. Remove old version of Docker $ sudo apt-get remove docker docker-engine docker.io containerd runc 2. Installing Docker Engine $ sudo apt-get update $ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common $ curl -fsSL https: $ sudo apt-key fingerprint EBFCD88 $ sudo add-apt-repository \ $ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io $ sudo docker run hello-world //download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 0 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable nightly test" // Check if docker is successfully installed in your system Create an application in Docker 1. Create a folder with 2 files (Dockerfile and main.py file) in it. . ├── Dockerfile └── main.py directories, files 0 2 2. Edit main.py with the below code. print(“Docker is magic!”) #!/usr/bin/env python3 3. Edit Dockerfile with the below commands. FROM python:latest COPY main.py / CMD [ “python”, “./main.py” ] 4. Create the Docker image. Once you have created and edited the file and the , . main.py Dockerfile create your image to contain your application $ docker build -t python-test . The ’-t’ option allows to define the name your image. ’python-test’ is the name we have choosen the image. of for 5. Run the Docker image Once the image is created, your code is ready to launch. $ docker run python-test Push an Image to Docker Hub 1. Create an Account on . Docker Hub 2. Click on “ button, put the name of file and click on “ . Create Repository” Create” 3. Now will “ and “ which we just created. tag our image” push it to the Docker Hub repository” # Run commend to list docker images $ docker images this The above will give us this result REPOSITORY TAG IMAGE ID CREATED SIZE afrozchakure/python-test latest c7857f97ebbd hours ago MB 2 933 is used to tag the image. The syntax to tag the image is: Image ID docker tag <image-id> <your dockerhub username>/python-test:latest $ docker afrozchakure/python-test:latest tag c7857f97ebbd 4. Push image to Docker Hub repository $ docker push afrozchakure/python-test Fetch and run the image from Docker Hub 1. To remove all versions of a particular image from our local system, we use the for it. Image ID $ docker rmi -f af939ee31fdc 2. Now run the image, it will fetches the image from docker hub if it doesn’t exist on your local machine. $ docker run afrozchakure/python-test Conclusion: So you have learnt about the basics of Docker, the difference between Virtual Machines and Docker Containers along with some common Terminologies in Docker. Also we went through the installation of Docker on our systems. We created an application using Docker and pushed our image to Docker Hub. Lastly we learned how we could remove a particular image from our local system and later pull the image from Docker Hub if it doesn’t exist locally.