Day 19 Task: Docker for DevOps Engineers

An professional with 5+ years of experience in devops and good knowledge of Automation Testing Python Programming Language and HTML,CSS. DevOps Tools : Jenkins,Docker,Git,artifatory,Sonar,ansible, monitoring tools like grafana and Prometheus. Proficient in understanding the requirements specification, analysing the existing process and writing automation scripts using Python, Experience in Agile Methodology,Scrum. Good knowledge on Test Development Life Cycle (SDLC). Well acquainted with Atlassian Support tools (Jira, confluence, bitbucket, Artifactory), also hands of experience on jira data migration and upgradation Hands on experience on Linux (CentOS) ,Linux administrator. Good knowledge about AWS cloud computing,SQL
#devops#docker
Docker-Volume
Docker allows you to create something called volumes. Volumes are like separate storage areas that can be accessed by containers. They allow you to store data, like a database, outside the container, so it doesn't get deleted when the container is deleted. You can also mount from the same volume and create more containers having the same data.
Docker Network
Docker allows you to create virtual spaces called networks, where you can connect multiple containers (small packages that hold all the necessary files for a specific application to run) together. This way, the containers can communicate with each other and with the host machine (the computer on which the Docker is installed). When we run a container, it has its own storage space that is only accessible by that specific container. If we want to share that storage space with other containers, we can't do that.
Task-1
Use the
docker-compose upcommand with the-dflag to start a multi-container application in detached mode.Use the
docker-compose scalecommand to increase or decrease the number of replicas for a specific service. You can also addreplicasin deployment file for auto-scaling.Use the
docker-compose pscommand to view the status of all containers, anddocker-compose logsto view the logs of a specific service.Use the
docker-compose downcommand to stop and remove all containers, networks, and volumes associated with the application
version: '3.9'
services:
my_web_app:
container_name: "django-application"
build: .
ports:
- 8001:8001
volumes:
- django_todo_volume:/app
my_db:
container_name: "django-mysql-db"
image: mysql:5.7
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: "test@12"
volumes:
django_todo_volume:
docker-compose up -d
ubuntu@ip-172-31-80-39:~/django-todo-cicd$ ubuntu@ip-172-31-80-39:~/django-todo-cicd$ docker-compose up -d
django-application is up-to-date
Recreating django-mysql-db ... done

You can check the running container

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 --mountcommand.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.

commands to create docker volume:
docker volume create --name django_todo_volume --opt type=none --opt device=/home/ubuntu/volumes/django-todo --opt o=bind

you can see in the above-created folder all the data which is attached to /app in the container will come under the folder once it is mounted even if you kill the container you can recreate the crash container using below command
docker run -d -p 8001:8001 --mount source=django_todo_volume,target=/app django-app-latest-volume:latest

Thank you for reading this Blog. Hope you learned something new today! If you found this blog helpful, please like, share, and follow me for more blog posts like this in the future.
I would like to connect with you at https://medium.com/@madhuripatiletc48


![Day 17 Docker Project for DevOps Engineers [Django app using docker]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1682179659134%2F09606564-0ebe-4163-940f-eaeec654d3bb.jpeg&w=3840&q=75)
