2
votes

I need to split a teamcity build that builds and pushes a docker image into a docker registry into two separate builds.

a) The one that builds the docker image and publishes it as an artifact

b) The one that accepts the docker artifact from the first build and pushes it into a registry

The log says, that there are these three commands running:

docker build -t thingy -f /opt/teamcity-agent/work/55abcd6/docker/thingy/Dockerfile /opt/teamcity-agent/work/55abcd6
docker tag thingy docker.thingy.net/thingy/thingy:latest
docker push docker.thingy.net/thingy/thingy:latest

There's plenty of other stuff going on, but I figured that this is the important part.

So I have copied the initial build two times, with the first command in the first build, and the next two in the second build.

I have set the first build as a snapshot dependency for the second build, and run it. And what I get is:

FileNotFoundError: [Errno 2] No such file or directory: 'docker': 'docker'

Which probably is because some of the files are missing.

Now, I did want to publish the docker image as an artifact, and make the first build an artifact dependency, but I can't find where does the docker put its files and all of the searches containing a "docker" and a "file" in them just lead to a bunch of articles about what the Dockerfile is.

So what can I do to make it so that the second build could use the resulting image and/or enviroment from the first build?

1

1 Answers

4
votes

in all honesty I didn't understand what exactly you are trying to do here.

However, this might help you:

You can save the image as a tar file:

docker save -o <image_file_name>.tar <image_tag>

This archive can then be moved and imported somewhere else.

You can get a lot of information about an image or a container with "docker inspect":

docker inspect <image_tag>

Hope this helps.