Skip to content

Instantly share code, notes, and snippets.

@zergin
Last active August 29, 2015 14:24
Show Gist options
  • Save zergin/d0d526a0e5fce1070552 to your computer and use it in GitHub Desktop.
Save zergin/d0d526a0e5fce1070552 to your computer and use it in GitHub Desktop.
docker-issue-14347

Docker 1.7.x --volumes-from regression

It would seem that 1.7.x introduced regression that ro/rw status for --volumes-from is set on first container use (not per running instance). It is now not possible to use the same data container both mounted as ro and rw in different.

This works on 1.6.2 and earlier.

Example

make tests

Creates minimal test case and shows that usage execution order matters for volume binding.

Examples use jq for parsing inspect output; so be warned...

FROM busybox
RUN mkdir /data
.PHONY: test clean
.IGNORE: clean distclean
tests:
docker build -t "tests/docker-issue-14347" .
docker run --name di-14347-data -v $(CURDIR):/data "tests/docker-issue-14347"
@echo "Running containers..."
docker run --name di-14347-user1 --volumes-from di-14347-data:ro "tests/docker-issue-14347"
docker run --name di-14347-user2 --volumes-from di-14347-data:rw "tests/docker-issue-14347"
@echo "Inspecting volumes..."
docker inspect di-14347-user1 | jq -C .[0].VolumesRW # should give "/data": false
@echo "Expected false."
docker inspect di-14347-user2 | jq -C .[0].VolumesRW # should give "/data": true
@echo "Expected true."
$(MAKE) clean
@echo "Running reverse..."
docker run --name di-14347-user1 --volumes-from di-14347-data:rw "tests/docker-issue-14347"
docker run --name di-14347-user2 --volumes-from di-14347-data:ro "tests/docker-issue-14347"
@echo "Inspecting volumes..."
docker inspect di-14347-user1 | jq -C .[0].VolumesRW # should give "/data": true
@echo "Expected true."
docker inspect di-14347-user2 | jq -C .[0].VolumesRW # should give "/data": false
@echo "Expected false."
$(MAKE) clean
clean:
@echo "Cleaning..."
docker rm -f di-14347-user1
docker rm -f di-14347-user2
distclean: clean
docker rm -f di-14347-data
docker rmi -f "tests/docker-issue-14347"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment