Docker for Devops   Engineer

Docker for Devops Engineer

Docker-Volume

Docker Volume is a way to store and manage data in Docker containers. It is a mechanism for sharing files and directories between a host machine and a Docker container or between multiple containers.

Using Docker Volume has several benefits. First, it enables you to separate data from the container's filesystem, which makes it easier to manage and backup. Second, it allows you to share data between multiple containers, which can help you to build more complex applications. Finally, Docker Volume makes it easier to move your containers between different machines or cloud environments, as the data can be easily transferred along with the container.

Docker Network

Docker network is a feature that enables communication between Docker containers running on the same host or across multiple hosts. It provides a private network that is isolated from the host network and enables containers to communicate with each other using their IP addresses or container names. Docker networks also support several features like DNS resolution and network security.

Task-1

  • Create a multi-container docker-compose file which will bring UP and bring DOWN containers in a single shot ( Example - Create application and database container )

  • Use the docker-compose up command with the -d flag to start a multi-container application in detached mode.

  • Use the docker-compose scale command to increase or decrease the number of replicas for a specific service. You can also add replicas in deployment file for auto-scaling.

  • Use the docker-compose ps command to view the status of all containers, and docker-compose logs to view the logs of a specific service.

  • Use the docker-compose down command to stop and remove all containers, networks, and volumes associated with the application

Clone your Repository

Creating docker-compose file

Use the docker-compose up command with the -d flag to start a multi-container application in detached mode.

Use the docker-compose ps command to view the status of all containers,

docker-compose logs to view the logs of a specific service.

Use the docker-compose down command to stop and remove all containers, networks, and volumes associated with the application

Task-2

  • Learn how to use Docker Volumes and Named Volumes to share files and directories between multiple containers.

  • Create two or more containers that read and write data to the same volume using the docker run --mount command.

  • Verify that the data is the same in all containers by using the docker exec command to run commands inside each container.

  • Use the docker volume ls command to list all volumes and docker volume rm command to remove the volume when you're done

Creating the volume for the container

  • Mount your volume to the container

  • Verify that the data is the same in all containers by using the docker exec command to run commands inside each container.

    THAT'S ALL FOR TODAY'S LEARNING I HOPE YOU LEARN SOMETHING FROM THIS BLOG