You have access to a Linux server with a few Docker containers. Some containers are running, some have exited successfully, and one appears to have crashed. Your goal is to list all containers and inspect their statuses.
Explore the environment and answer the questions below.
Hint 1: Listing currently running containers ๐ก
Listing containers is one of the most basic operations in Docker.
You can use docker ps
(alluding to the ps
command from Unix) or a longer but more explicit docker container ls
command for it.
Hint 2: Listing all containers in the system ๐ก
By default, docker ps
shows only running containers.
Run docker ps --help
to see if there is a way to show all containers,
including exited and crashed ones.
Hint 3: Enhancing the "docker ps" output ๐ก
The nicely-looking short IDs that you get from the default docker ps
output are actually just prefixes of the full container IDs.
You can use the the docker ps
with the --no-trunc
flag to see the full IDs.
Hint 4: Inspecting container details ๐ก
While some attributes of containers can be found from the docker ps
output,
it's often useful to inspect the container in more detail.
You can use the following command to inspect the container's details:
docker inspect CONTAINER_ID|NAME
Or its more explicit variant:
docker container inspect CONTAINER_ID|NAME
Level up your Server Side game โ Join 11,000 engineers who receive insightful learning materials straight to their inbox