Docker for DevOps.

What is Docker volume?
Docker volumes are widely used and useful tools for ensuring data persistence while working in containers. They are a better alternative than compiling additional writable layers, which increase Docker image size.
Docker volumes are file systems mounted on Docker containers to preserve data generated by the running container.
The volumes are stored on the host, independent of the container life cycle. This allows users to back up data and share file systems between containers easily.
What is Docker Network?
Docker connects to the bridge network by default; this allows deployed containers to be seen on your network. Letβs see how we can manage those networks, create a new network, and then deploy a container on our new network.
To view the current list of Docker networks, issue the command:
docker network ls
The above command will list out the Docker networks.
Task-1
- Create a multi-container docker-compose file which will bring UP and bring DOWN containers in a single shot .
version: '3'
services:
app:
image: my_app_image
volumes:
- my_volume:/app/data
database:
image: my_db_image
volumes:
- my_volume:/var/lib/db
volumes:
my_volume:
π To start this multi-container application, use:
docker-compose up
π And to stop and remove all associated containers, networks, and volumes:
docker-compose down
Docker Networks: Connecting Containers Seamlessly
Docker networks provide a virtual space where containers can communicate with each other and the host machine. Each container has its own storage space, but Docker networks enable sharing this space among multiple containers.
Creating Docker Networks
π To create a Docker network:
docker network create my_network
π Containers can then be connected to this network:
docker run -d --name container1 --network my_network my_image
docker run -d --name container2--network my_network my_image
I hope this article will help you to understanding the concept of docker networking.
HAPPY LEARNING.
###

