LinuxCommandLibrary

docker-containers

List Docker containers

TLDR

List currently running Docker containers

$ docker container ls
copy

Start one or more stopped containers

$ docker container start [container1_name] [container2_name]
copy

Kill one or more running containers

$ docker container kill [container_name]
copy

Stop one or more running containers

$ docker container stop [container_name]
copy

Pause all processes within one or more containers

$ docker 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 container export [container_name]
copy

Create a new image from a container's changes

$ docker container commit [container_name]
copy

SYNOPSIS

The 'docker-containers' concept does not have a single command synopsis as it represents a collection of docker subcommands. Here are synopses for two of the most fundamental operations related to Docker containers:

1. Listing Containers:
docker ps [OPTIONS]

2. Running a New Container:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

PARAMETERS

-a, --all
    For docker ps: Show all containers (default shows just running ones).

-d, --detach
    For docker run: Run container in the background and print the container ID.

-it
    For docker run: Allocate a pseudo-TTY and keep stdin open, commonly used for interactive shells.

--name string
    For docker run: Assign a specific name to the container.

-p, --publish list
    For docker run: Publish a container's port(s) to the host's ports.

--rm
    For docker run: Automatically remove the container when it exits.

--format string
    For docker ps: Pretty-print containers using a Go template for custom output.

DESCRIPTION

The term "docker-containers" does not refer to a standalone Linux command. Instead, it serves as a conceptual grouping for the various subcommands within the docker CLI that are used to manage the lifecycle of Docker containers. A Docker container is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Docker provides a robust set of tools for interacting with containers, allowing users to run new containers, list running or exited containers, stop active containers, start stopped ones, remove containers, and inspect their properties or logs. These operations are performed using the main docker command followed by a specific subcommand (e.g., docker run, docker ps, docker stop, docker rm). The underlying technology leverages Linux kernel features like namespaces and cgroups to isolate processes.

CAVEATS

The primary caveat is that 'docker-containers' is not an executable command itself. All interactions with Docker containers are done via the docker CLI tool and its various subcommands. Users must have Docker installed and the Docker daemon running to perform any container operations. Commands often require appropriate user permissions (e.g., being part of the 'docker' group or using sudo).

CONTAINER LIFECYCLE

Docker containers transition through various states:
Created: The container has been created but not started.
Running: The container is actively executing its primary process.
Paused: The container's processes have been suspended.
Stopped/Exited: The container's primary process has finished or been terminated; it still exists on disk.
Removed: The container has been deleted from the system.

CONTAINER VS. IMAGE

An Image is a read-only template with instructions for creating a Docker container. It's like a blueprint for an application. A Container is a runnable instance of an image. You can create, start, stop, move, or delete a container. Multiple containers can be run from the same image, each isolated from the others.

HISTORY

The concept of containers has existed for decades in various forms (e.g., FreeBSD Jails, Solaris Zones, Linux VServer, LXC). However, the modern surge in containerization was largely ignited by the release of Docker in 2013. Docker simplified the packaging, distribution, and running of applications in isolated environments, making container technology accessible and widely adopted. Its user-friendly CLI and image management system rapidly popularized the use of Linux containers, leading to a paradigm shift in software development and deployment methodologies, especially within DevOps practices and cloud-native architectures.

SEE ALSO

docker(1), docker-run(1), docker-ps(1), docker-stop(1), docker-start(1), docker-rm(1)

Copied to clipboard