3

Ive been learning about Docker for the last months, I was watching one training tutorial on udemy. I did docker ps -a to check the containers I have (all of them) and for learning purposes I was looking for a command that gives me the full container id of a container.

docker ps -a

Lets say that from this picture, I want the full container_id of: 8a7815ffd059

thanks in advance!

5 Answers 5

6

Directly with the ps command:

docker ps --no-trunc 

With inspect:

docker inspect 8a78 | grep Id 
Sign up to request clarification or add additional context in comments.

Comments

1

Lets say that from this picture, I want the full container_id of: 8a7815ffd059

docker inspect 8a78 | grep Id 

Comments

1

This command should give you what you want:

docker container inspect --format "{{.Id}}" 8a78 

and nothing besides the container id (e.g., no cruft to sort through)

Comments

0

If you do:

docker inspect ${the id you get in docker ps} 

You get a pretty big json with all the details about the container. The first key in the object is Id, which is what you are looking for

Comments

0

If you want the container id without the container running, this solves it:

docker inspect --format="{{.Id}}" <container_name> | sed 's/sha256://g' 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.