The docker cp command at the end of the example does not work since the docker container (extracted from DOCKER_MACHINE_NAME) seems to not exist.
I think it is possible to access this remote docker engine since the step setup_remote_docker produces an output containing informations to access it, like this one:
Allocating a remote Docker Engine
Waiting for a Docker Engine assignment: ....................
Assigned Docker Engine request id: 50483050
provisioning:
Remote Docker engine created. Using VM 'default-bfd82105-046c-4732-a529-fe90b3e9df94'
Created container accessible with:
DOCKER_CERT_PATH=/tmp/docker-certs385546227
DOCKER_HOST=tcp://35.185.33.90:2376
DOCKER_MACHINE_NAME=50483050
DOCKER_TLS_VERIFY=1
NO_PROXY=127.0.0.1,localhost,circleci-internal-outer-build-agent,35.185.33.90:2376
My question is: how can I access this remote docker engine in order to copy the build artefacts to the circle ci primary container in order to cache it?
In my experience it takes more time to export the layers, cache them, and restore them, than it does it just let the layers rebuild every time. YMMV - I am using an alpine-based image, which drastically improved my build times.
Hi @ajhodges, thanks for sharing that. I love seeing creative ways for folks to do things like this. Some people like to pay money for making things easy, but I’m a fan of figuring out things myself as well.
For sure! I can appreciate why DLC is a paid feature. This workaround will probably only be useful to those with long image build times and relatively small images.
But please don’t contact me for support because I only did enough to get it working well enough to know that it wasn’t worth spending any more time on for my use case
Thanks @drazisil, I SSH’d into the CircleCi job and then in the remote docker image but this one looks empty (there is only a build folder and none of the build artefacts or even applications folders related to my app.
Even when I re start the build command while SSH’d into the main CircleCI VM (docker build -t my-tag --build-arg APP_ENV=$(APP_ENV) .) I don’t see anything in the remote docker image.
Same thing when I try to scp the _build folder produced on the remote docker to the base CircleCI docker image (scp remote-docker:/app/_build/ .), I get the error scp: /app/_build: No such file or directory.
It looks like the remote docker image I connect to is not the good one, or maybe I am not able to see its content with ssh / scp ?
I successfully used scp to copy over my generated code coverage files for storage as artifacts. If anyone else is looking to do that, it looks something like this (assuming your working directory is called project):
For anyone coming along later ssh remote-docker takes you onto the host running docker, not into the docker container itself.
Once on the remote host you need to run appropriate docker commands eg docker run --rm -d --name container -it <image>:<tag> tail -f /etc/hosts docker cp container:/path/to/content ~/content scp remote-docker:content ~/project/content