# Day 19 Task: Docker for DevOps Engineers

## Docker-Volume:-

Docker volumes are **file systems mounted on Docker containers to preserve data generated by the running container**. The data doesn't persist when that container no longer exists, and it can be difficult to get the data out of the container if another process needs it.

## Docker Network:-

What is the Docker network?

![Image result for docker network](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ9HVnqXS9LRe13YDI5bh3e62Sgrqt51GjtLjna-R5eLw&s align="left")

Docker networking **enables a user to link a Docker container to as many networks as he/she requires**. Docker Networks are used to provide complete isolation for Docker containers. Note: A user can add containers to more than one network. Let's move forward and look at the Advantages of networking.

## Task-1

* Create a multi-container docker-compose file that will bring *UP* and bring *DOWN* containers in a single shot ( Example - Create application and database container )
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681566123161/0873d7b9-f5cd-4b79-8e34-3e16db8d89c3.png align="center")
    
* **Use the docker-compose up command with the -d flag to start a multi-container application in detached mode.**
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681566068972/89f07437-3715-4f5a-87a6-3f28b896fe06.png align="center")
    
* **Use the docker-compose scale command to increase or decrease the number of replicas for a specific service. You can also add** [**replicas**](https://stackoverflow.com/questions/63408708/how-to-scale-from-within-docker-compose-file) **in deployment file for *auto-scaling*.**
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681567107579/6e03753f-d5bc-4170-8c04-a20954381054.png align="center")
    
    **Use the docker-compose ps command to view the status of all containers**
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681567139027/fc057a55-f252-45f3-ae1b-5a7608ec0342.png align="center")
    
    **Use the docker-compose logs to view the logs of a specific service.**
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681567553129/5a6167f1-5681-40fe-9e88-cff09ce799c8.png align="center")
    
    **Use the docker-compose down command to stop and remove all containers, networks, and volumes associated with the application**
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681567666721/cb627e54-8b2d-4b19-a57a-1b45dd3c3269.png align="center")
    
    ## **Task-2**
    
    **Learn how to use Docker Volumes and Named Volumes to share files and directories between multiple containers.**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674408243089/30875d53-c5b9-4b3f-a5a6-626472a06853.png?auto=compress,format&format=webp align="left")
    
    **Create two or more containers that read and write data to the same volume using the docker run --mount command.**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674414210453/594c064f-9037-4dfb-aba4-3bcccca7775e.png?auto=compress,format&format=webp align="left")
    
    **Verify that the data is the same in all containers by using the docker exec command to run commands inside each container.**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674414721998/2ff38b42-5ead-4d99-ae65-522ab6238441.png?auto=compress,format&format=webp align="left")
    
    **Use the docker volume ls command to list all volumes**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674410955407/470ed2c9-b56e-424a-b0e9-8f142bcdc76f.png?auto=compress,format&format=webp align="left")
    
    **Use the docker volume rm command to remove the volume when you're done**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674411342881/b5d69527-acd8-4e34-94c4-8414ba29bb4c.png?auto=compress,format&format=webp align="left")
    
    * Hope you like this blog. Please follow for more blogs like this.....
        
        Thank you.
