We have completed✅ the Docker hands-on and I hope you have learned something interesting from it.🙌
Now it's time to take your Docker skills to the next level by creating a comprehensive cheat-sheet of all the commands you've learned so far. This cheat-sheet should include commands for both Docker and Docker-Compose, as well as brief explanations of their usage. This cheat-sheet will not only help you in the future but also contribute to the DevOps community by providing a useful resource for others.
Here's a comprehensive Docker cheat sheet that covers various Docker commands and concepts
Docker Basics:
Images: Templates that contain the filesystem and configuration needed to run a container.
docker images
: List all available images.docker pull <image_name>:<tag>
: Download an image from a repository.docker rmi <image_name>:<tag>
: Remove an image.
Containers: Instances of Docker images running as isolated processes.
docker ps
: List running containers.docker ps -a
: List all containers (including stopped ones).docker run <image_name>:<tag>
: Create and start a new container.docker start <container_id>
: Start a stopped container.docker stop <container_id>
: Stop a running container.docker rm <container_id>
: Remove a container.
Dockerfile: Text file with instructions to build a Docker image.
FROM <base_image>
RUN <command>
COPY <src> <dest>
WORKDIR <directory>
EXPOSE <port>
CMD <command>
Docker Compose: Tool for defining and running multi-container applications.
docker-compose up
: Start containers defined indocker-compose.yml
.docker-compose down
: Stop and remove containers.docker-compose up -d
: Start the container in detach modedocker-compose stop:
Stop container started by docker-compose updocker-compose ps:
List container defined in a docker-compose.ymldocker-compose logs:
View all logs defined in a docker-compose.yml
Docker Networking:
docker network ls
: List all networks.docker network create <network_name>
: Create a new network.docker network connect <network_name> <container_name>
: Connect a container to a network.docker network disconnect <network_name> <container_name>
: Disconnect a container from a network.
Docker Volumes:
Volumes: Persistent data storage that can be shared between containers and the host.
docker volume ls
: List all volumes.docker volume create <volume_name>
: Create a new volume.docker run -v <volume_name>:<container_path>
: Mount a volume into a container.
Docker Registry:
Docker Hub: A public registry for Docker images.
docker login
: Log in to a Docker registry.docker push <image_name>:<tag>
: Upload an image to a registry.
Docker Management:
docker logs <container_id>
: View logs of a container.docker exec -it <container_id> <command>
: Execute a command inside a running container.docker inspect <container_id>
: View detailed information about a container.docker stats
: Display live performance data for all containers.
Docker Cleanup:
docker system prune
: Remove all unused images, containers, networks, and volumes.docker system prune -a
: Remove all images, containers, networks, and volumes.
Remember that this cheat sheet provides only a quick overview of Docker commands and concepts. For more in-depth information and usage details, refer to the official Docker documentation.
Happy Learning!