My Docker Cheat Sheet

Run a new container

docker run <container id or name>

Start a stopped container

docker start <container id or name>

Stop a container

docker stop <container id or name>

Kill a container

docker kill <container id or name>

Restart a container

docker restart <container id or name>

List all running containers

docker ps

List all containers

docker ps -a

List with formatted output (here only show name and status of containers)

docker ps --format '{{.Names}} {{.Status}}'

Inspect a container

docker inspect <container id or name>

List all ports a container uses

docker container port <container id or name>

Open Bash in container (‘exit’ to close)

docker exec -it <container id or name> bash

Watch STDOUT from container (‘-f’ for continued logging)

docker logs <container id or name>

Search containers in registry (example: “MySQL” gives all available MYSQL-containers)

docker search <search word>

Pull container from registry

docker pull <name>

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.