Is it possible to write to a volume mounted to a docker image on a machine executor?

We are attempting to set up a test environment for some of our authentication code in CircleCI. The actual test isn’t an issue, except in that we believe we are constrained to using machine executors because we need to run multiple docker containers that talk to each other in a particular sequence.

The problem at hand is how to access the cache from inside one of those containers. In our build we are:

  • Restoring our (sbt) cache
  • Starting a docker container and attaching the cache as a volume
  • Executing code inside that container that uses and, in the process, updates that cache.

The update part fails. Our docker container has the user circleci that is executing the code, which is the user being used in the machine executor. Except these users have different UIDs and the one inside the container does not have the same permission as the one outside the container. The one outside the container owns the volume, and is the only one who can write to it.

Is there a way for the user inside the container to update the cache that is mounted as a volume? We can play around with groups and permissions, but it’s unclear if how circle is using docker will allow any of that to work.

Would you be looking to mount a volume container on an on-host volume (bind mount)? The latter won’t work because it doesn’t work across networks, but if memory serves correctly, the former does work.

Give that a try first, and if it does work, maybe you could use docker cp to copy cache contents into it.