Hello Readers,
Here we are Day 16 of #90daysofdevops
👣 Topics for #day16
Intro to Docker
Docker Hub
Steps to install Docker in Ubuntu
Commands to use Docker
Tasks of Day 16
Intro to Docker
Docker is a platform that allows you to build, package, and run applications and their dependencies in a containerized environment.
It is designed to make it easier to develop, deploy, and run applications in different environments without worrying about dependencies and compatibility issues.
A Docker container is a lightweight and standalone executable package that includes everything needed to run an application, such as the code, runtime, system tools, libraries, and settings.
Containers are isolated from the host operating system and other containers, so they provide a consistent and reproducible environment for running applications.
Docker uses a client-server architecture, where the Docker client communicates with the Docker daemon, which runs on the host operating system.
The Docker client allows you to interact with the Docker daemon, such as creating, running, and managing containers, images, and other Docker objects.
Docker images are used to build containers. An image is a read-only template that contains instructions for creating a Docker container. It includes the application code, runtime, system tools, libraries, and dependencies required to run the application.
You can create an image from scratch, or use an existing image as a base image and customize it as per your requirements.
Docker Hub
Docker Hub is a cloud-based registry service provided by Docker that allows you to store, manage, and share Docker images. It is a centralized repository for Docker images and provides a platform for developers to share and collaborate on containerized applications.
Docker Hub allows users to search for and download pre-built Docker images for popular applications, such as MySQL, Node.js, and NGINX.
Users can also upload their own Docker images to Docker Hub and share them with others. Docker Hub makes it easy to share images with others, whether it be with your team, your organization, or the wider community.
Docker Hub is also integrated with other Docker tools, such as Docker Desktop and Docker Cloud, which makes it easy to push and pull images from Docker Hub directly from the command line. This integration also makes it easy to deploy Dockerized applications to cloud platforms like Amazon Web Services, Microsoft Azure, and Google Cloud Platform.
Steps to install Docker on Ubuntu
sudo apt-get update
sudo apt-get docker.io
sudo reboot
sudo systemctl status docker
sudo apt-get update
: This command updates the package list on the Linux system. It is necessary to ensure that the system has the latest information about available packages before installing any new software.sudo apt-get install
docker.io
: This command installs Docker on the Linux system using the Advanced Packaging Tool (APT). Thedocker.io
package is available in the Ubuntu repositories, and this command installs it along with any dependencies.sudo reboot
: This command restarts the Linux system. It is a good practice to reboot the system after installing new software to ensure that all changes are applied correctly.sudo systemctl status docker
: This command checks the status of the Docker service.
Commands to use Docker
docker build
: This command builds a new Docker image from a Dockerfile.docker run
: This command creates and runs a new container from a Docker image.docker pull
: This command downloads a Docker image from a registry, such as Docker Hub.docker push
: This command uploads a Docker image to a registry, such as Docker Hub.docker ps
: This command lists all running containers on the system.docker stop
: This command stops a running container.docker rm
: This command removes a stopped container.docker rmi
: This command removes a Docker image from the system.docker exec
: This command runs a command inside a running container.docker logs
: This command displays the logs of a container.docker inspect
: This command displays detailed information about a Docker object, such as a container or image.
Tasks of Day 16
docker ps
This command will list all the running containers.
docker run
This command starts a new container based on the image and runs it.You can interact with the container through the command line by using the
docker exec
command.docker images
This command will list all images that are currently available on your Docker host.
docker inspect
This command will show you detailed information about the specified container or image. For example,
docker inspect <id>
will display a JSON object with detailed information about the container.
docker stats
This command will show real-time resource usage statistics for the container. The output will include information such as CPU usage, memory usage, network I/O, and disk I/O.
docker top
This command will show the processes running inside the container. The output will include information such as the process ID, user, CPU usage, memory usage, and command.
docker save
This command will save the specified image to a tar archive named "anyname.tar" in the current directory.
docker load
This command will load the "anyname.tar" archive and create a new image with the same name.
Thank you for reading my Blog. I hope you have learnt something from it! If you find this blog helpful, please like, share, and follow me for more interesting posts like this in the future.