Unable to use "docker cp", but it worked 2 days ago

ubuntu@box723:~/kukni.to$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                            NAMES
a6b4d1a8bc93        kuknito/mongo2es        "/bin/sh -c 'bash $ME"   12 minutes ago      Up 12 minutes       0.0.0.0:3001->80/tcp                             Mongo2ES
a6fb48610577        kuknito:elasticsearch   "bin/elasticsearch"      12 minutes ago      Up 12 minutes       0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   ElasticSearch
7b20b7903447        mongo:3.0               "/entrypoint.sh mongo"   12 minutes ago      Up 12 minutes       27017/tcp, 0.0.0.0:27018->27018/tcp              MongoDB
ubuntu@box723:~/kukni.to$ docker cp scripts/masterCategories.json MongoDB:/data/masterCategories.json
Error response from daemon: permission denied

was something changed regarding docker recently? docker cp used to work just 2 days ago, now when I rerun the same build where it worked, it no longer works and gives the error above.

2 Likes

my temporary solution until this is fixed is creating the file in the container like this:

sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' MongoDB)" -- bash -c "cat > /data/masterCategories.json" < scripts/masterCategories.json

Am having the exact same problem. docker cp was working in our CI jobs yesterday, stopped work in all of our builds / branches this morning. From a recent run:

+ docker cp hosted-build-web:/go/bin/web /tmp/hosted-build-web/bin/

Error response from daemon: permission denied

It’s worth noting that we install our own version of docker / docker-machine using the following machine config in circle.yml:

machine:
  pre:
    - sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
    - sudo chmod 0755 /usr/bin/docker
    - sudo curl -o /usr/local/bin/docker-compose -L https://github.com/docker/compose/releases/download/1.5.1/docker-compose-`uname -s`-`uname -m`
    - sudo chmod +x /usr/local/bin/docker-compose

Have also tried upgrading those versions to latest to no avail.

1 Like

I use the default docker version provided by circleCI.
I couldn’t see anything about docker in recent changes in circle’s changelog.
I created a support request for this with link to this thread. Hopefully it will get fixed soon.

Does this workaround work for you as well?

Thank you for reporting this issue. Due to some security concerns we had to upgrade the version of LXC that runs on our builder boxes. It looks like this has broken docker cp our Engineers are looking into the cause of the issue and hope to have a resolution soon. In the meantime it looks like the workaround posted by @Alino should work:

sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' MongoDB)" -- bash -c "cat > /data/masterCategories.json" < scripts/masterCategories.json

Reply
2 Likes

I don’t think it will work for @klingerf , my workaround is very limited to a single text file, copying from host to docker container, and klingerf seems that he wants to copy whole directory from docker container to host.

[Updated 17th Dec]

I just patched docker and pushed to our public download site. It looks docker cp is working now.

To use the patched version, you can put the following in your circle.yml. Please make sure to replace <version>.

Available versions:
1.8.2
1.8.3
1.9.0
1.9.1

machine:
  pre:
    - echo 'DOCKER_OPTS="-s btrfs -e lxc -D --userland-proxy=false"' | sudo tee -a /etc/default/docker
    - sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-<version>-circleci-cp-workaround'
    - sudo chmod 0755 /usr/bin/docker
  services:
    - docker

Please report us if you find any problems.

2 Likes

@kimh Thank you for providing the patched version! It doesn’t work for our build unfortunately because our setup uses docker-compose 1.5, which requires docker >= 1.9. Any chance you can also provide a patched version of 1.9.1, which was introduced in this thread:

Alternatively, I can look into a solution similar to the one @Alino provided. We might be able to use tar or another utility to get the files out of the container.

@klingerf

Just patched 1.9 as well. Does 1.9 work for you? I need a bit more time to do 1.9.1, but will be done in a few hours.

machine:
  pre:
    - echo 'DOCKER_OPTS="-s btrfs -e lxc -D --userland-proxy=false"' | sudo tee -a /etc/default/docker
    - sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.0-circleci-cp-workaround'
    - sudo chmod 0755 /usr/bin/docker
  services:
    - docker
2 Likes

Hi @kimh – the patched version you provided fixes my issue. Thanks for all of your help with this!

@klingerf Patched and uploaded 1.9.1 as well.

2 Likes

Hi @kimh

Thank you for the great news.
I had the same problem, then docker-1.9.0-circleci-cp-workaround worked well for me.

1 Like