How to get the full id of a Docker container

When working with Docker containers, it's common to need the full ID of a container for various management tasks. Let's walk through how you can easily retrieve this information.
First, open your terminal or command prompt. This is where you'll enter the commands to interact with Docker.
To get the full ID of a Docker container, you'll use the docker ps
command. This command lists all the running containers on your system. However, by default, it only shows the short ID of the containers. To see the full ID, you need to modify the command a bit.
Type the following into your terminal:
docker ps --no-trunc
The --no-trunc
flag tells Docker not to truncate the output, which means you'll see the full container ID instead of the shortened version.
When you run this command, you'll see a list of your running containers. The first column of the output will now display the full container ID. It will look something like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f321d19f... ubuntu:latest "/bin/bash" 10 minutes ago Up 10 minutes ecstatic_easley
In this example, 9f321d19f...
(truncated for readability) is the full container ID for the container named "ecstatic_easley".
If you only want to see the full ID of a specific container, you can combine docker ps
with the --filter
or -f
option. For instance, if you want to find the full ID of a container with a specific name, you could use:
docker ps --no-trunc -f name=ecstatic_easley
This command will show only the container with the name "ecstatic_easley", and you'll see its full ID in the output.
Remember, these commands only show running containers. If you need the full ID of a stopped container, you can add the -a
flag to docker ps
:
docker ps -a --no-trunc
This will list all containers, both running and stopped, with their full IDs.
By using these commands, you can easily retrieve the full ID of any Docker container on your system, which is useful for tasks like stopping, starting, or inspecting containers in more detail.