Day #20: Docker CheatSheet for DevOps

Release Management Professional | Transitioning to DevOps
With a proven track record in Release Management, I'm on an exciting journey to transition into the world of DevOps. I specialize in orchestrating the smooth deployment of software and applications, and I'm now gearing up to bridge the gap between development and operations.
My passion lies in optimizing release processes, automating deployments, and ensuring the efficiency of IT operations. I'm actively enhancing my skill set in DevOps practices, including cloud technologies, scripting, and CI/CD pipelines.
I'm keen to connect with professionals who share this enthusiasm and explore opportunities for mutual growth and collaboration in the DevOps domain. Let's connect and exchange insights about the evolving landscapes of Release Management and DevOps!
#ReleaseManagement #DevOps #EfficiencyOptimization
Introduction
Docker has revolutionized the way we build, ship, and run applications. This Docker cheatsheet and guide will walk you through the essential commands in a friendly and easy-to-understand manner.
Docker Basics:
1. Installation:
Docker Desktop is available for Mac, Linux, and Windows. It simplifies the installation and management of Docker, allowing developers to get started quickly. Detailed installation instructions can be found in the official Docker documentation.
Windows/macOS:
Download Docker Desktop from https://www.docker.com/products/docker-desktopLinux:
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io
2. Check Docker Version:
docker --version
3. Hello World:
docker run hello-world
Managing Containers:
4. Run a Container:
docker run -d --name my_container nginx
-d: Run in the background (detached).--name: Assign a name to the container.
5. List Running Containers:
docker ps
6. Stop and Start a Container:
docker stop my_container
docker start my_container
7. Remove a Container:
docker rm my_container
Working with Images:
8. List Downloaded Images:
docker images
9. Pull an Image:
docker pull alpine
10. Remove an Image:
docker rmi alpine
Building Images:
11. Dockerfile:
Create a file named Dockerfile with instructions to build an image.
FROM ubuntu:latest
RUN apt-get update && apt-get install -y python3
12. Build an Image:
docker build -t my_custom_image .
Networking:
13. Create a Bridge Network:
docker network create my_network
14. Run a Container on a Specific Network:
docker run --network my_network -d nginx
Data Volumes:
15. Create a Volume:
docker volume create my_volume
16. Run a Container with a Volume:
docker run -v my_volume:/app/data -d my_image
Docker Compose:
17. Docker Compose File (docker-compose.yml):
version: '3'
services:
web:
image: nginx
db:
image: mysql
18. Run Docker Compose:
docker-compose up
19. Stop Docker Compose:
docker-compose down
20. Login into Docker:
docker login -u <username>
21. Publish an image to Docker Hub:
docker push <username>/<image_name>
22. Search Hub for an image:
docker search <image_name>
Conclusion:
Docker is a powerful tool that can simplify your development and deployment workflows. This cheatsheet provides a starting point, but there's much more to explore. As you delve deeper into the world of containers, Docker's official documentation will be your best companion.




