moby: Can't push multiple images to same repo in parallel

Attempting to push multiple images to the same remote in parallel cases one of the push operations to fail. The operation claims “is already in progress”, implying that the image is already being pushed, but this is false. The image is not pushed, and pushing again at a later time will end up actually pushing the image.

$ cat > Dockerfile <<'EOF'
FROM fedora:20
ADD file /file
RUN dd if=/dev/zero of=zero bs=1M count=10
EOF

$ echo 1 > file

$ docker build -t phemmer/test:1 .

$ echo 2 > file

$ docker build -t phemmer/test:2 .

$ docker push phemmer/test:1 & docker push phemmer/test:2 ; wait
[1] 31920
The push refers to a repository [phemmer/test] (len: 1)
Sending image list
2014/11/12 20:38:02 Error: push phemmer/test is already in progress
[1]  + exit 1     docker push phemmer/test:1
Pushing repository phemmer/test (1 tags)
511136ea3c5a: Image already pushed, skipping 
c69cab00d6ef: Image already pushed, skipping 
88b42ffd1f7c: Image already pushed, skipping 
64dd2ddab00b: Image successfully pushed 
712a4eb2c2eb: Image successfully pushed 
Pushing tag for rev [712a4eb2c2eb] on {https://cdn-registry-1.docker.io/v1/repositories/phemmer/test/tags/2}

In this case, the phemmer/test:2 image successfully pushed, but phemmer/test:1 failed.

Docker version 1.3.1

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 28 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Not sure if this has been mentioned, but the most obvious workaround is

#!/bin/bash
# /usr/local/sbin/docker-push
exec flock -x /var/lock/docker-pool docker push "${@}"
#!/bin/bash
# /usr/local/sbin/docker-pull
exec flock -x /var/lock/docker-pool docker pull "${@}"

You can probably tune it further so that the lock is per repo, e.g. /var/lock/docker-pool-${repo}.