Skip to content

Commit 39bf96c

Browse files
authored
Only check parent container bind mounts (#10)
1 parent 8ee50b3 commit 39bf96c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

dond

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function set_parent_container_mounts() {
113113
local docker_output
114114
docker_output=$(
115115
"${docker_path}" inspect \
116-
--format '{{range .Mounts}}{{printf "%s:%s\n" .Source .Destination}}{{end}}' \
116+
--format '{{range .Mounts}}{{if eq .Type "bind"}}{{printf "%s:%s\n" .Source .Destination}}{{end}}{{end}}' \
117117
"${container_id}"
118118
)
119119

scripts/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ for docker_version in "${docker_versions[@]}"; do
5858
docker --host test run --volume /wd:/wd:ro --volume /test:/test:ro alpine --volume /wd:/wd |
5959
grep --quiet "^docker.orig --host test run --volume ${fixtures_dir}:/wd:ro --volume /container-root/test:/test:ro --volume ${fixtures_dir}/testfile:/test/testfile:ro alpine --volume /wd:/wd$"
6060

61+
echo "Same as above but should not auto add mounts which are not bind mounts"
62+
"${docker_args[@]}" --env DOND_SHIM_PRINT_COMMAND=true --env DOND_SHIM_MOCK_CONTAINER_ROOT_ON_HOST=/container-root --volume "${fixtures_dir}:/wd" --volume "${fixtures_dir}/testfile:/test/testfile" --mount type=tmpfs,target=/test/tmpfsdir "${image_id}" \
63+
docker --host test run --volume /wd:/wd:ro --volume /test:/test:ro alpine --volume /wd:/wd |
64+
grep --quiet "^docker.orig --host test run --volume ${fixtures_dir}:/wd:ro --volume /container-root/test:/test:ro --volume ${fixtures_dir}/testfile:/test/testfile:ro alpine --volume /wd:/wd$"
65+
6166
echo "Same as above (with --mount src and target, dst), but retaining read only mode on auto added volume"
6267
"${docker_args[@]}" --env DOND_SHIM_PRINT_COMMAND=true --env DOND_SHIM_MOCK_CONTAINER_ROOT_ON_HOST=/container-root --volume "${fixtures_dir}:/wd" --volume "${fixtures_dir}/testfile:/test/testfile" "${image_id}" \
6368
docker --host test run --mount type=bind,src=/wd,target=/wd,readonly --mount type=bind,source=/test,dst=/test,readonly alpine --mount type=bind,source=/wd,destination=/wd,readonly |

0 commit comments

Comments
 (0)