This page is under regular updates. Please check back later for more content.
Managing Containers

Managing Containers

Common commands overview

CommandDescription
docker ps [-a]Shows currently running containers. Adding -a displays both running and stopped (past) containers.
docker startStarts a container from a locally stored image.
docker stopStops a container using Linux SIGTERM, allowing it to terminate gracefully.
docker restartRestarts a currently running or stopped container.
docker killStops a container using Linux SIGKILL, which forces immediate termination.
docker rmRemoves container files from the host operating system after stopping the container.

Inspecting container setting

CommandDescription
docker psShows the IDs of currently running containers.
docker inspect <ID>Inspects the container's details and pipes the output to less for easier reading.
docker inspect --format='{{.NetworkSettings.IPAddress}}' containernameDisplays the IP address of a specific container by its name.
docker inspect --format containernameInspects the container and returns details using a specific format defined by the user.
ps aux on the host machineFinds the container's PID (Process ID) on the host system.
Output
controlplane $ docker inspect --format='{{.NetworkSettings.IPAddress}}' xander
172.17.0.2
controlplane $ docker inspect --format='{{.State.Pid}}' xander
47704
controlplane $ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                   NAMES
684c0acaa0c5   nginx     "/docker-entrypoint.…"   3 minutes ago   Up 3 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp   xander