Skip to main content

Docker CLI

Commands

🌐 docs.docker.com

Main commands

CommandAction
docker --versionDisplay Docker CLI version
docker infoDisplay Docker general information
docker container --helpDisplays help for container command
docker container ls --allList all containers
docker psGet all running containers
docker ps --allGet all containers
docker rm <containerid>Delete a container by its id
docker imagesGet all images on the system
docker versionGet Docker version (Client + Server)
docker run hello-worldRun Hello world image
docker run -it ubuntu bashRun Ubuntu image with an interactive shell
docker network lsList networks
docker network inspect bridgeInspect network bridge
docker exec -it <containerid> shExecute a shell command on a running container
docker start <containerid>Start an existing container
docker stop <containerid>Stop a running container
docker logs <containerid>See last logs of a container
docker system prune --volumesDelete all unused objects (pruning)

Examples

# builds a new image
docker build . -t myrepo/myimage:mytag -f mypath/Dockerfile --no-cache

# runs a new container
docker run -p 8011:80 -e ASPNETCORE_ENVIRONMENT=Development --name mycontainername myrepo/myimage:mytag

Cheat sheets