CI\CD container agents using volumes

Current setup

  • Using docker 1.10.3
  • ci\cd agent is running as a docker container
    • This container is passed the docker socket using a volume
    • Has the docker cli installed - no daemon
  • ci\cd polls for repo changes
  • ci\cd pulls latest repo content on repo change and gets the agent to execute build instructions
    • This gets executed within the ci\cd agent container instance


  • I cannot pass the current directory as a volume within the ci\cd agent container
  • The source for a volume is a path on the host

Any suggestions for getting around this issue ?


  • This is a simplified version of the Dockerfile used to create the agent containers
FROM ubuntu:latest

RUN     apt-get update \
        && apt-get install -y -q apt-transport-https \
        && apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D \
        && mkdir -p /etc/apt/sources.list.d \
        && echo "deb [arch=amd64] ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list \
        && apt-get update \
        && apt-get install -y -q docker-engine \
        && rm -rf /var/lib/apt/lists/*
  • Commands to use the above and demo the issue
# Build a simple agent
docker build -t ci-agent .

# Create local files
touch file1
touch file2

# Run an agent container that gets the docker version - Success
docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock ci-agent bash -c 'docker version'

# Run an agent container that tries to pass data using a volume - failure - empty dir
docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $PWD:/build ci-agent bash -c 'cd /build; docker run --rm -ti -v /build:/other ubuntu find /other'

# This is just to show it will work based on the host file system - Based on the ubuntu user existing on the host
# Run an agent container that tries to pass data using a volume based on the host filesystem - Sucess
docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock ci-agent bash -c 'docker run --rm -ti -v /home/ubuntu:/other ubuntu find /other'