Find a better Docker Cheat Sheet, Kubernetes Cheat Sheet and Helm Cheat Sheet at

Image Management

List available images

docker images

Pull a docker image

docker pull [Image-Name]

Search for new docker images

docker search [Image-Name]

Remove a docker image

docker rmi [Image-Name]:[Tag]

Remove all non-running docker images

docker rm $(docker ps -a -q)

Check the JSON file of an image

docker inspect [Image-Name]

Process Management

Show all running docker containers

docker ps

Show all docker containers

docker ps -a

Run an interactive container

docker run -it [Image-Name]

Run a container in disconnected mode

docker run -d [Image-Name]

Stop a container

docker stop [Container ID]

Kill a container

docker kill [Container ID]

Attach to a container with an interactive shell

docker exec -it [Container ID] /bin/bash

Run a new docker container

docker run [Image-Name]:[Tag]

Ports and Volumes

Forward traffic from a port on localhost to your container

docker run -d -p [Local Port]:[Container's Port] [Image-Name]

Forward traffic from a random localhost port to your container

docker run -d -P [Image-Name]

Mount a directory to a container

docker run -v [Directory] [Image-Name]

Leave a Reply

Your email address will not be published. Required fields are marked *