Day 20 Task: Docker Cheat Sheet
π³ Docker Cheat Sheet: Streamlining Container Operations! π
Greetings, DevOps enthusiasts! Excited to share a Docker cheat sheet to navigate the container seas efficiently. Let's dive in! π οΈ
Docker Commands:
Build an Image:
docker build -t your-image-name:tag .Builds a Docker image from the current directory.
Run a Detached Container:
docker run -d -p host-port:container-port your-image-name:tagSpins up a detached container, mapping ports for accessibility.
List Running Containers:
docker psDisplays active containers and their vital details.
Inspect Container Details:
docker inspect container-idFetches in-depth information about a specific container.
View Container Logs:
docker logs container-idRetrieves and displays logs for a specific container.
Stop and Remove Containers:
docker stop container-id docker rm container-idGracefully stops and removes a running container.
Bonus Tips:
Run Without Sudo:
sudo usermod -aG docker $USEREnables running Docker commands without sudo.
Remove Docker Images:
docker rmi image-idDeletes a Docker image.
Conclusion:
Docker is a powerhouse for container orchestration, and mastering these commands empowers efficient operations. Keep this cheat sheet handy for smooth sailing in the containerized world!