Docker Commands Cheatsheet With Examples
Docker Commands Cheatsheet With Examples
2. Run a Container
o Command: docker ps
o Command: docker ps -a
5. Stop a Container
6. Remove a Container
7. Pull an Image
9. Remove an Image
o Example: docker inspect ubuntu → Shows details about the Ubuntu image.
Mayank_Singh
o Example: docker import container.tar → Creates an image from the tar file.
o Example: docker run -p 8080:80 nginx → Maps host port 8080 to container port 80.
o Example: docker save -o my-app.tar my-app → Saves "my-app" image as a tar file.
o Example: docker load < my-app.tar → Loads "my-app" image from the tar file.
o Example: docker run -d --name my-nginx nginx → Runs NGINX container named "my-
nginx."
o Example: docker run --cpus="1.5" nginx → Limits the container to 1.5 CPUs.
o Example: docker run -it ubuntu bash → Starts an interactive Ubuntu shell.