Build and deploy docker image without pushing

docker
deploy

#1

Hi all,

I am trying to build, save and deploy a docker image on CircleCI, but without pushing the image to Docker Hub. In CircleCI 1.0 I could do so by building the docker image using Maven, then save it using docker save command, and finally deploy it just by uploading the saved docker image file to the deployment server, where it then is loaded and ran.

Now, with CircleCI 2.0, I am struggling with this, as we now have this “remote docker container” where all the Docker specific commands are executed. Therefore, my docker save command runs there, which means that the resulting docker image file is also only available in that remote docker container. Like that I can’t deploy it to my deployment server now, right?

My idea is to just copy the saved docker image from the remote docker container to the main job container where all other CircleCI commands are executed. Afterwards, I should be able to deploy it as usual. Is it possible to do this (copy)? How?

If this is not possible: any other ideas on how I can deploy a build docker image to my server without pushing it to Docker Hub first?

Thanks in advance!


#2

Please, I need help with this. Without this, I can’t migrate to CircleCI 2.0 :cry:


#3

Hey @flogy, are you sure your docker save command outputs to the remote docker environment?
I have the following in one of my builds and that works fine:

  - run:
      name: Do the docker build
      command: |
        docker build -f Dockerfile -t your_project:$CIRCLE_BRANCH .
        mkdir -p docker-cache
        docker save -o docker-cache/built-image.tar your_project:$CIRCLE_BRANCH 
  - save_cache:
      key: *docker_cache_key
      paths:
        - docker-cache

That allows me to persist the built image from this job and pick it up later in another job for further uses (like deployment).


#4

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.