Docker-compose.yml and volume mounts


#1

Hello I’m trying to convert a project to the new circle 2.0 docker beta, but running into issues with volume mounts.

The docker-compose.yml looks like the following:

  suite:
    ...
    volumes:
      - .:/app
      - $CIRCLE_TEST_REPORTS/rspec:/app/report

But when I running docker-compose run --rm --no-deps suite bash -c "ls -la /app", the folder is reported to just contain “report” and nothing from $PWD / first volume.

The command works as expected locally.

Is there anything special around volume mounts?


Keep images between each tests
.circleci/config.yml with more than one Docker image
Getting Started: Docker Engine
Getting Started: Docker Engine
#2

I think the problem is that ENVARS are not yet supported in circle.yml, can you hard code that path?

This will be supported in the future.


#3

Hardcoding the path is also not working, you can find an example build here: https://circleci.com/gh/contentful/api_integration_suite/9447


#4

The path you used is absolute from the root. Can you try this?

docker-compose run --service-ports suite /home/ubuntu/api_integration_suite/script/run_tests.sh

As long as you stay in the workDir this should work too:

docker-compose run --service-ports suite ./script/run_tests.sh

#5

I’m not sure I understand. As said when running docker-compose run --rm --no-deps suite bash -c "ls -la /app" the container contains only the report folder but nothing from the current working directory. The path shouldn’t really matter as the command is executed within the container.


#6

You are correct. I mistook that part.


#7

Hi Johannes,

Sorry for the delay in getting back to you. The replies in the Getting Started thread got out of hand and I’m breaking them off into separate threads now.

Thanks for sharing a link to your build. I see that it’s on the docker executor. To answer your original question:

Volume mounts will not work on the docker executor because the Docker host running your container is different from the Docker host that you’re controlling with docker-compose. Remote volume mounting isn’t possible with our setup, but you can get volume mounting with the machine executor.


Docker in docker not mounting volumes
#8

I am running into a similar problem. With my setup, I have to run three Docker containers to test and each one is run using a Docker run command with various volume mounts and environment variables. It looks like for some reason volume mounting isn’t taking the files from the host into the Docker containers. I have a hunch it has something to do with the remote Docker Engine. Maybe its volume mounting from that remote host rather than the actual build image?


#9

@wlaoh volume mounts currently only work on the machine executor. You’re correct, this does have to do with limitations around a remote Docker Engine. I don’t have more details beyond that, though.


#10

Hello,

How can I change the docker engine version with machine executor? Basically I need to use volumes on a newer docker engine version.

Here is the error message I get when I change to the machine executor:

  • In step 7 (setup_remote_docker): Step isn’t compatible with machine executor. You can use docker without a special step.

Thanks in advance for the clarifications.


#11
sudo rm -rf /usr/bin/docker
curl -sSL https://get.docker.com/ | sh
Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:06 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:06 2017
 OS/Arch:      linux/amd64
 Experimental: false

#12

In CircleCI 2.0, you can use two different docker “executors” :

  • docker executor : run your stuffs in a docker container, for some reasons it’s not possible to mount external volumes when you use your docker (which is inside the CircleCI docker)
  • machine executor : run your stuffs in a VM, here it’s possible to mount external volumes.
    What’s concerning is that the machine executor is stated as a “Potential Premium Feature Notice: Machine Executor may be available for additional fees in a future pricing update.” (https://circleci.com/docs/2.0/executor-types/#machine-executor-overview).
    I find it crazy, a free feature in Circle 1.0 (being able to mount external volumes with Docker) may be charged with Circle 2.0… I hope you guys will never apply fees for this.

Docker-compose doesn't mount volumes with host files with Circle-Ci
#13

I’ve been debugging this one for a few days. Disappointed to see CircleCI 2.0 is losing its shine fast- I’d thought the update was about improved docker support, but instead we’ve had to hack around the lack of built-in docker image caching between jobs and poor volume support.


#14