setup_remote_docker with circle ci 2.1 in a job running on a docker executor.
jobs: test-job: working_directory: ~/repo/api docker: - image: circleci/elixir:1.6 steps: - setup_remote_docker - run: name: Build application Docker image command: | docker build -t my-tag --build-arg APP_ENV=$(APP_ENV) . # copy build artefacts from remote docker to circle ci primary container in order to cache it - run: docker -D -H $DOCKER_HOST --tls --tlscert $DOCKER_CERT_PATH/cert.pem cp $DOCKER_MACHINE_NAME:/app/_build/. ./_build/
The dockerfile used by the
docker build command is this one:
FROM elixir:1.6.6 # install dependencies RUN mix local.hex --force && \ mix local.rebar --force && \ mix hex.info ARG APP_ENV=prod WORKDIR /app ENV MIX_ENV=$APP_ENV ADD . . RUN mix deps.get RUN mix release --env=$MIX_ENV SHELL ["/bin/bash", "-l"] CMD ["/bin/bash", "-l", "/app/_build/prod/rel/creative_platform/bin/creative_platform", "foreground"]
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://188.8.131.52:2376 DOCKER_MACHINE_NAME=50483050 DOCKER_TLS_VERIFY=1 NO_PROXY=127.0.0.1,localhost,circleci-internal-outer-build-agent,184.108.40.206: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?