LinuxCommandLibrary

docker-container

Manage (create, start, stop) Docker containers

TLDR

List currently running Docker containers

$ docker [[ps|container ls]]
copy

Start one or more stopped containers
$ docker [[start|container start]] [container1_name] [container2_name]
copy

Kill one or more running containers
$ docker [[kill|container kill]] [container_name]
copy

Stop one or more running containers
$ docker [[stop|container stop]] [container_name]
copy

Pause all processes within one or more containers
$ docker [[pause|container pause]] [container_name]
copy

Display detailed information on one or more containers
$ docker container inspect [container_name]
copy

Export a container's filesystem as a .tar archive
$ docker [[export|container export]] [container_name]
copy

Create a new image from a container's changes
$ docker [[commit|container commit]] [container_name]
copy

SYNOPSIS

docker container COMMAND [OPTIONS] [ARG...]

PARAMETERS

--config
    Location of client config files

--context
    Name of context to connect to daemon

--debug
    Enable debug mode

--help
    Print usage information

--log-level
    Set logging level (debug|info|warn|error|fatal)

--version
    Print version information

DESCRIPTION

The docker container command is a key component of the Docker CLI, providing a unified interface to manage containers—lightweight, portable, executable packages that encapsulate applications and their dependencies. This subcommand group enables users to create, run, monitor, and delete containers efficiently, supporting modern DevOps workflows, microservices, and cloud-native deployments.

Docker containers use OS-level virtualization for superior efficiency over traditional VMs, sharing the host kernel while isolating processes. Common tasks include launching interactive shells (docker container run -it), listing active containers (docker container ls), viewing logs (docker container logs), and resource stats (docker container stats). It integrates seamlessly with Docker images, networks, and volumes.

Ideal for developers testing locally, sysadmins scaling production, or teams using CI/CD pipelines, it abstracts complex virtualization into simple commands. Requires a running Docker daemon and often elevated privileges. Enhances reproducibility across environments from laptops to clusters.

CAVEATS

Requires Docker daemon; root or docker group access often needed. Subcommands have additional options—use docker container COMMAND --help for details. Not all subcommands support all global flags.

KEY SUBCOMMANDS

attach, commit, cp, create, exec, inspect, kill, logs, ls, pause, prune, rm, run, start, stats, stop, top, unpause, update, wait.
Use docker container --help for full list.

EXIT CODES

0: Success
1: Generic error
125: Requested subcommand unavailable
126: Subcommand invoked with invalid args
127: Subcommand not found/invalid.

HISTORY

Restructured into subcommand groups like docker container in Docker 1.13 (March 2017, API 1.25) for better organization. Evolved from original flat CLI; Docker originated 2013 by dotCloud, now maintained by Docker Inc. and Moby project.

SEE ALSO

docker(1), podman-container(1), docker-run(1), docker-image(1)

Copied to clipboard