Docker formation and Deployment

Navneet Tiwari
4 min readMar 29, 2023

--

First, we start with the question “What is Docker?”

So, in it’s own words: Docker is an open-source platform for developing, shipping, and running applications.

Docker containers are lightweight, portable, and self-sufficient, allowing developers to package their applications and dependencies into a single, reproducible unit that can be easily deployed across different environments.

How Docker Works:

At its core, Docker is a containerization platform that allows you to run applications in containers. Containers are similar to virtual machines, but they are more lightweight and portable. Unlike virtual machines, which require a complete guest operating system to run, containers use the host operating system and share system resources, such as the kernel and CPU.

What is a Docker Image:

Docker provides a simple and efficient way to package an application and its dependencies into a single unit, called a Docker image. Docker images can be easily shared and used to deploy applications on any platform that supports Docker. Docker also provides a centralized registry where developers can store and share their Docker images and it is known as Docker Hub. You can pull any pre-built docker image or push your custom made image on Docker hub.

What is a Docker Container:

Docker container is a lightweight and portable runtime environment that contains an application and its dependencies, making it easy to deploy and manage applications across different systems and environments.

When you start a Docker container, it is like launching a virtual machine that contains everything the application needs to run, including the code, libraries, and system tools. However, unlike a virtual machine, Docker containers are lightweight and share the host operating system kernel. This makes them faster and more efficient than traditional virtual machines.

  • You can find basic commands and their explaination here:

itachiuchiha11

What is Docker Hub and How to use it:

Docker Hub is a service provided by Docker for finding and sharing container images.

It’s the world’s largest repository of container images with an array of content sources including container community developers, open source projects and independent software vendors (ISV) building and distributing their code in containers.

To use Docker Hub, you will first need to create an account on the Docker Hub website. Once you have created an account, you can start pushing your Docker images to Docker Hub using the docker push command.

  • Here are the basic steps to use Docker Hub:

Build your Docker image: Before you can push your Docker image to Docker Hub, you need to build it using the docker build command. This command will create a Docker image based on the Dockerfile that you have specified. You have to move to the directory that contains the Dockerfile where you can simply run the following command to build the image:

# docker build -t myimage .

Tag your Docker image: After you have built your Docker image, you need to tag it with your Docker Hub username and the name of the image. For example, if your Docker Hub username is “myusername” and you want to tag your image as “myimage”, you would use the command:

# docker tag myimage:tag myusername/myimage:tag

Login to Docker Hub: Before you can push your Docker image to Docker Hub, you need to login to your Docker Hub account using the docker login command. This command will prompt you to enter your Docker Hub username and password.

# docker login

Push your Docker image: Once you have logged in to Docker Hub, you can push your Docker image using the docker push command. This command will upload your Docker image to your Docker Hub account.

# docker push myusername/myimage:tag

Once your Docker image has been pushed to Docker Hub, you can easily share it with other developers by giving them the Docker image name and tag. They can then pull the image from Docker Hub using the docker pull command and run it on their own system:

# docker pull myusername/myimage:tag

If you want to share your container and image to someone using a .tar file, you can convert it into one and share it with them:

# docker container export containerID > filename.tar

They can simply give the docker import command to import the .tar file directly:

# docker image import filename.tar newimage

It will create a new image and then they can simply run the “docker build” the command to build the container and run it with “docker run” command to run the services of the Docker.

In conclusion, Docker Hub is a powerful tool for managing and sharing Docker images. By using Docker Hub, you can easily distribute your Docker images and collaborate with other developers to build and deploy applications.

--

--