🐳Day 20 - Docker Cheat sheet for DevOps Engineer.
🐳Docker Basics:
docker version
: Check Docker version.docker info
: Display system-wide information about Docker.docker --help
: Get help on Docker commands.
💽Images:
docker pull <image_name>
: Download an image from Docker Hub or a registry.docker images
ordocker image ls
: List locally available images.docker rmi <image_id>
: Remove a local image.docker build -t <image_name> <path_to_dockerfile>
: Build a Docker image from a Dockerfile.docker history <image_name>
: Show the history of an image.docker tag <image_id> <new_image_name>:<tag>
: Tag an image for a specific version.
🚢Containers:
docker run -it <image_name>
: Create and start a new container.docker ps
ordocker container ls
: List running containers.docker ps -a
ordocker container ls -a
: List all containers, including stopped ones.docker start <container_id>
: Start a stopped container.docker stop <container_id>
: Stop a running container.docker restart <container_id>
: Restart a container.docker rm <container_id>
: Remove a container.docker exec -it <container_id> <command>
: Run a command in a running container.
🌐Networking:
docker network ls
: List Docker networks.docker network create <network_name>
: Create a new Docker network.docker network connect <network_name> <container_id>
: Connect a container to a network.docker network disconnect <network_name> <container_id>
: Disconnect a container from a network.docker port <container_id>
: List port mappings for a container.
🔊Volumes:
docker volume ls
: List Docker volumes.docker volume create <volume_name>
: Create a new Docker volume.docker run -v <volume_name>:<container_path> <image_name>
: Mount a volume to a container.docker cp <local_file> <container_id>:<container_path>
: Copy files between a container and the host.
🗃️Registry and Repository:
docker login
: Log in to a Docker registry.docker logout
: Log out from a Docker registry.docker push <image_name>
: Push an image to a registry.docker pull <image_name>
: Pull an image from a registry.docker search <image_name>
: Search for images on Docker Hub.
📝Docker Compose:
docker-compose up
: Start containers defined in adocker-compose.yml
file.docker-compose down
: Stop and remove containers defined in adocker-compose.yml
file.docker-compose ps
: List containers in adocker-compose.yml
file.docker-compose logs
: View container logs from adocker-compose.yml
file.docker-compose build
: Build services defined in adocker-compose.yml
file.
💡Miscellaneous:
docker logs <container_id>
: View container logs.docker stats <container_id>
: Display a live stream of container resource usage.docker top <container_id>
: Display running processes in a container.docker inspect <container_id>
: View detailed information about a container.docker-compose version
: Show the Docker Compose version.
📚Happy Learning :)
Subscribe to my newsletter
Read articles from Sarika Kamble directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sarika Kamble
Sarika Kamble
👋 Hello, and welcome to my DevOps journey! 🚀 I'm Sarika Kamble, passionate about all things AWS DevOps Technology. Currently, on a learning adventure, I'm here to share my journey and Blogs in the world of cloud and DevOps. I'll be sharing my learnings, experiences, and adventures as I dive deep into the world of continuous integration, automation, and cloud technologies. ☁️⚙️ Let's connect, learn, and grow as a vibrant DevOps community. Follow my Hashnode blog, and let's embrace the DevOps adventure together! 🤝🔗 Follow me on LinkedIn: https://www.linkedin.com/in/sarika-kamble-3153b3218/