Skip to content
StackDecode
BeginnerLesson 4 of 26

Everyday CLI commands

The handful of commands you will use every day.

bash
docker run -d --name web -p 8080:80 nginx   # start in the background
docker ps                                    # running containers (-a for all)
docker logs -f web                           # follow the output
docker exec -it web sh                       # open a shell inside
docker stop web && docker rm web             # stop, then remove
docker system prune                          # clean up unused data
  • -d detaches, --name gives a friendly name.
  • docker exec runs an extra command in a running container.
  • Remove stopped containers regularly; they accumulate.