0

Is it possible to log the exact version of a Docker image used in BitBucket pipelines?

We have a custom Docker image that is at version 1.8 for example. In our bitbucket-pipelines.yml we use the latest version of this image:

image: ourImage:1

But when we look at older builds, it would be useful to know which version of the image was used at the time. Was it 1.8 or maybe 1.7 or 1.6 or ...?

Is it possible to log the image version in a Docker container or in BitBucket pipelines? Or to find the version any other way?

Peter
  • 13,733
  • 11
  • 75
  • 122
  • You could always log/echo in bash the exact docker image tag in your first execution step. Not aware about other ways to find the exact tag. – Recoba20 Apr 20 '20 at 17:24
  • Not sure how I would do that. I don't know if bash inside the image is aware it's running in a Docker image. And in my Bitbucket pipeline, I'm only using the major version. – Peter Apr 21 '20 at 18:17
  • This schould be achievable, I have not tested it, but based on the docs and some research you get the container ID and then query the docker socket. https://confluence.atlassian.com/bitbucket/run-docker-commands-in-bitbucket-pipelines-879254331.html?_ga=2.107077250.1295314724.1587839132-388936134.1587839132#RunDockercommandsinBitbucketPipelines-RunningDockercommands%C2%A0 – Recoba20 Apr 25 '20 at 19:43

1 Answers1

0

Sorry, my answer is not passing the characters validation.

This schould be achievable, I have not tested it but based on the docs and some research you get the container ID and then query the docker socket. You might have to install some binaries and mount docker socket as a volume, but the overhead is tiny.

Docker daemon in BitbutBucket Pipelines

Get Container ID and query Docker Socket

Recoba20
  • 314
  • 1
  • 13