Cheatsheet Pages / Docker Cheatsheet

How to run a Docker container — docker run with ports and volumes

The one command that starts most containers: detached, named, with a port published and data kept in a volume.

docker run -d --name web -p 8080:80 -v webdata:/usr/share/nginx/html nginx:1.27
# -d detached, --name easy handle, -p host:container, -v volume:mount

Good to know

-d runs it detached, --name gives you an easy handle, -p maps host:container ports, -v mounts a volume.

Docker Cheatsheet one-page card — commands that actually work
The full one-page card — Docker Cheatsheet. Get the complete cheatsheet on GitHub