Docker Cheat Sheet - (05) - Day 37
Quick reference guide for Docker commands along with examples to help you get started.
Docker Build images
Docker Run containers
Docker Manage containers
docker version: Check the Docker version.
Example: docker versiondocker info: Display system-wide information about Docker.
Example: docker infodocker pull: Pull an image from a repository.
Example: docker pull ubuntu:latestdocker run: Create and start a container from an image.
Example: docker run -it --rm ubuntu:latest
docker ps: List running containers.
Example: docker psdocker ps -a: List all containers (including stopped ones).
Example: docker ps -adocker exec: Run a command in a running container.
Example: docker exec -it container_name /bin/bashdocker stop: Stop a running container.
Example: docker stop container_namedocker start: Start a stopped container.
Example: docker start container_namedocker restart: Restart a running container.
Example: docker restart container_name
docker rm: Remove a stopped container.
Example: docker rm container_namedocker rmi: Remove an image.
Example: docker rmi ubuntu:latestdocker build: Build an image from a Dockerfile.
Example: docker build -t my_image_name .docker images: List available images.
Example: docker imagesdocker-compose up: Start services defined in a Compose file.
Example: docker-compose up -d
docker-compose down: Stop and remove containers, networks, and volumes defined in a Compose file.
Example: docker-compose downdocker network creates: Create a network.
Example:docker network create my_networkdocker volume creates: Create a volume.
Example: docker volume create my_volumedocker logs: View logs from a container.
Example: docker logs container_namedocker inspect: Display detailed information about a container or image. Example: docker inspect container_name
You can replace the command options, image names, and container names with your own choices.
You can also refer below images for your reference:
Thank you for reading. Happy Learning ๐!!!