-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Race condition when populating volumes with nested volumes #11663
Comments
One more thing: The reason for the
I'm not able to reproduce the error that way, if I set
Not sure how that fits into the whole picture though. |
Can you please clarify the need for second volume Also, as you compare this with a plain |
As I said, I agree that this is not optimal. There isn't any necessity to have those nested volumes, but the config occurs like this due to a default setting.
Yes in the current setup the volume in necessary as it must be populated with as directory tree at first start. I'm aware that there are ways to work aroung this but since the behavior of this particular case is inconsistent and might change with every run, I thought I report it as a bug to save others the time to dig through it again. |
right, but in your |
I believe #11706 is related as overlapping configs/volumes will also trigger a race condition. |
I tried it, but it's not exactly the same. With plain docker I couldn't get it to succeed. It always fails but sometimes it complains about being not able to chmod the subdir and sometime it complains about not being able to mount the subdir cause it doesn't exist.
Script for plain docker# parameters
NO_VARS=2550
NO_RUNS=99
NO_INC_SIZE=3
TEST_PATH=/tmp
cd $TEST_PATH
cat << EOF > Dockerfile
FROM debian:latest
# create dirs to populate
RUN mkdir -p /foo/bar /foo/baz /foo/subdir
RUN touch /foo/bar/iamhere
# create a larger container size
RUN for i in \$(seq 1 $NO_INC_SIZE); do \
cp -rv /usr /foo/baz/$i/ >/dev/null 2>&1; \
done
CMD sleep .1
EOF
# build container
docker build -t race:condition .
# create a larger env file
rm -f .env
for i in $(seq 0 $NO_VARS); do
echo "VAR$i=$i" >> .env
done
echo "TEST_PATH=$TEST_PATH" >> .env
# loop to reproduce
rm -f debug-docker.log
for no in $(seq 0 $NO_RUNS); do
docker rm -f docker-rc-test >/dev/null 2>&1
mkdir -p parent >/dev/null 2>&1
rm -rf parent/* >/dev/null 2>&1
docker volume rm -f rc-parent >/dev/null 2>&1
docker volume rm -f rc-subdir >/dev/null 2>&1
docker volume create --driver local --opt type=none --opt device=$TEST_PATH/parent --opt o=bind rc-parent >/dev/null 2>&1
docker volume create --driver local --opt type=none --opt device=$TEST_PATH/parent/subdir --opt o=bind,ro rc-subdir >/dev/null 2>&1
# test & report
docker run -d --name docker-rc-test --env-file .env -v rc-parent:/foo -v rc-subdir:/foo/bar --rm race:condition #>> debug-docker.log 2>&1 && echo "$no: success" || echo "$no: failed"
done |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as not stale anymore due to the recent activity. |
This issue has been automatically marked as not stale anymore due to the recent activity. |
Description
We have a customer setup where a volume is bind mounted into a container and the container populates it with some files on first start.
Later another volume was added which is a subdirectory inside the first volume. This subdirectory gets created by the file population of the container at first start.
Now I'm aware this is not a really self consistent concept and therefore might be bad practice, however the problem is that is sometimes fails and sometime succeeds which is worse then just getting a error.
Steps To Reproduce
I tried to stay a close to the original setup as possible while removing everything which is not necessary. This is what I came up with to reproduce:
Since this is a race condition it might behave differently on other systems depending on CPU,IO,etc.
You can play around with the parameters in search for the "sweet spot". I did not find any config that always fails, but some that are more likely to succeed more often %)
Compose Version
Docker Environment
Anything else?
I'm posting this here because I'm not able to reproduce this with Docker alone. Eg.
mkdir -p state; rm -rf state/* state/.*; docker run --rm -ti -v ./state/log:/var/log -v state:/var debian bash
The text was updated successfully, but these errors were encountered: