Reputation: 3842
I am running this command in centos7 termnial:
docker pull www.someRepository.com/authorization:latest
Now, I want to run the "docker run" command, but I need to know the id of the image that was created
$id=commandThatParsesTheId
Is there a command that gets the id back from the "docker images" list?
Upvotes: 3
Views: 2520
Reputation: 121
docker pull someImage:latest
docker image inspect -f '{{ .ID }}' someImage:latest
Upvotes: 0
Reputation: 431
You might be able to clean this up a bit, but the following should work:
docker pull <someimage> | grep "Digest:" | cut -f2 -d " " > container_digest
docker images --digests | grep $(cat container_digest) | sed -Ee 's/\s+/ /g' | cut -f4 -d " "
It maps the digest you receive when you pull an image to the image ID.
Upvotes: 1
Reputation: 5763
you can run the "docker run" command on images name also instead of image id
docker pull www.someRepository.com/authorization:latest
docker run -i -t www.someRepository.com/authorization:latest "/bin/bash"
Above one is to run the container for interactive mode.
you can get image id also to run the docker run command
docker images
docker run -i -t dockerid "/bin/bash"
Upvotes: 0
Reputation: 906
You can use the name of image and its' tag Or you can use
docker images -q | grep yourimagename
docker images | grep yourimagename | awk {'print $3'}
Upvotes: 2