Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: How do I pull a specific build-id?

I would like to always pull a specific version, rather than just the latest.

A random example: https://registry.hub.docker.com/u/aespinosa/jenkins/builds_history/9511/

I am doing this because I only want to deploy versions that I have audited. Is this currently possible? Or am I forced to fork them and make my own?

like image 287
Sam Avatar asked Aug 22 '14 10:08

Sam


People also ask

How do I find my docker image ID?

The easiest way to list Docker images is to use the “docker images” with no arguments. When using this command, you will be presented with the complete list of Docker images on your system. Alternatively, you can use the “docker image” command with the “ls” argument.

What is docker build -- pull?

docker pull is used to pull from docker hub. If you use docker build without a docker file it throws an error. When you specify --pull or :latest docker will try to download the newest version (if any) Basically, if you add --pull, it will try to pull the newest version each time it is run.


2 Answers

You can pull a specific image by digest by using the following syntax:

docker pull ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 

If you need to find the hash, it is output when pushing/pulling the image. Some automated builds output it at the end. I tried looking for the hash with docker inspect but it didn't appear to be there, so you'll have to delete the image and pull it again to view the hash.

like image 190
Joel B Avatar answered Sep 22 '22 23:09

Joel B


The way I do it is to tag each build

docker build -t $NAMESPACE/$APP_NAME:$BUILD_SHA1 . docker tag $NAMESPACE/$APP_NAME:$SHA1  $DOCKER_REGISTRY/$NAMESPACE/$APP_NAME:$SHA1 docker push $DOCKER_REGISTRY/$NAMESPACE/$APP_NAME:$SHA1 

and then you pull the specific tag

docker pull $DOCKER_REGISTRY/$NAMESPACE/$APP_NAME:$SHA1 
like image 44
fabrizioM Avatar answered Sep 20 '22 23:09

fabrizioM