├── CHEATSHEET.md ├── INTERVIEW.md ├── LICENSE └── README.md /CHEATSHEET.md: -------------------------------------------------------------------------------- 1 | # Docker Cheatsheet for Beginners 2 | 3 | This cheatsheet is a beginner-friendly guide to Docker commands, covering the most commonly used commands for running and managing containers, working with images, and networking. It also includes a section on Docker Compose, which is a tool for defining and running multi-container applications. This cheatsheet is designed to help new users get started with Docker and become familiar with the most essential commands in a concise and easy-to-follow format. 4 | 5 | ## Running and managing containers 6 | 7 | - `docker run `: Run a container from an image 8 | - `docker start `: Start a stopped container 9 | - `docker stop `: Stop a running container 10 | - `docker kill `: Forcefully stop a running container 11 | - `docker attach `: Attach to a running container 12 | - `docker exec -it `: Run a command in an interactive shell in a running container 13 | - `docker rm `: Remove a stopped container 14 | - `docker inspect `: Inspect a container 15 | - `docker logs `: View logs for a container 16 | - `docker top `: View processes in a container 17 | 18 | ## Managing images 19 | 20 | - `docker images`: List available images 21 | - `docker rmi `: Remove an image 22 | - `docker history `: View the history of an image 23 | - `docker pull `: Download an image from a registry (e.g., Docker Hub) 24 | - `docker build -t .`: Build an image from a `Dockerfile` in the current directory and give it the specified name 25 | - `docker push `: Push an image to a registry 26 | - `docker tag `: Tag an image 27 | 28 | ## Managing container resources 29 | 30 | - `docker run --cpus= `: Limit the number of CPU cores available to a container 31 | - `docker run --memory= `: Limit the amount of memory available to a container 32 | 33 | ## Managing container metadata 34 | 35 | - `docker run --name= `: Assign a name to a container 36 | - `docker run -e = `: Set an environment variable in a container 37 | 38 | ## Managing container users 39 | 40 | - `docker run --user= `: Run a container as a specific user 41 | - `docker run --user=: `: Run a container as a specific user and group 42 | 43 | ## Managing container volumes 44 | 45 | - `docker run -v : `: Bind mount a host path to a container path 46 | - `docker run -v ::ro `: Bind mount a host path to a container path in read-only mode 47 | - `docker run -v `: Create a data volume in a container 48 | - `docker run --mount type=volume,src=,dst= `: Use a named volume in a container 49 | 50 | ## Managing container networks 51 | 52 | - `docker run --network `: Connect a container to a network 53 | - `docker run --network --ip `: Connect a container to a network and specify its IP address 54 | - `docker network create `: Create a new network 55 | - `docker network rm `: Remove a network 56 | 57 | ## Managing container ports 58 | 59 | - `docker run -p : `: Publish a container port to the host 60 | - `docker port `: View the port mappings for a container 61 | 62 | ## Managing container security 63 | 64 | - `docker run --security-opt=