HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

docker — Manage Docker containers and images. Some subcommands such as `container` and `image` have their own

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandimagesdockerandclimanagecontainers

Problem

How to use the docker command: Manage Docker containers and images. Some subcommands such as container and image have their own usage documentation. More information: <https://docs.docker.com/reference/cli/docker/>.

Solution

docker — Manage Docker containers and images. Some subcommands such as container and image have their own usage documentation. More information: <https://docs.docker.com/reference/cli/docker/>.

List all Docker containers (running and stopped):
docker {{[ps|container ls]}} {{[-a|--all]}}


Start a container from an image, with a custom name:
docker {{[run|container run]}} --name {{container_name}} {{image}}


Start or stop an existing container:
docker container {{start|stop}} {{container_name}}


Pull an image from a Docker registry:
docker {{[pull|image pull]}} {{image}}


Display the list of already downloaded images:
docker {{[images|image ls]}}


Open an interactive tty with Bourne shell (sh) inside a running container:
docker {{[exec|container exec]}} {{[-it|--interactive --tty]}} {{container_name}} {{sh}}


Remove stopped containers:
docker {{[rm|container rm]}} {{container1 container2 ...}}


Fetch and follow the logs of a container:
docker {{[logs|container logs]}} {{[-f|--follow]}} {{container_name}}

Code Snippets

List all Docker containers (running and stopped)

docker {{[ps|container ls]}} {{[-a|--all]}}

Start a container from an image, with a custom name

docker {{[run|container run]}} --name {{container_name}} {{image}}

Start or stop an existing container

docker container {{start|stop}} {{container_name}}

Pull an image from a Docker registry

docker {{[pull|image pull]}} {{image}}

Display the list of already downloaded images

docker {{[images|image ls]}}

Context

tldr-pages: common/docker

Revisions (0)

No revisions yet.