Docker 29 cheatsheet
Docker 29: Containers
13 common Docker 29 tasks.
Run a container in the background
Start a named container and publish host port 8080 to container port 80.
docker run -d --name web -p 8080:80 nginx
Run a throwaway shell with your code mounted
Start a temporary container, mount the current folder and delete the container when you exit.
docker run --rm -it -v "$(pwd)":/app -w /app node:24 bash
Remove a container
Delete a stopped container. Add -f to remove a running one.
docker rm web
Caution: Data stored in the container's own filesystem is lost. Data in named volumes is kept.
Open a shell in a running container
Run an interactive shell inside a container. Use bash if the image has it.
docker exec -it web sh
Copy a file out of a container
Copy a file from a container to the current folder.
docker cp web:/etc/nginx/nginx.conf ./nginx.conf