Skip to content

Commit

Permalink
Add support for named volumes (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs authored Oct 16, 2024
1 parent 317ba14 commit 96bd708
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dond
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function set_parent_container_mounts() {
local docker_output
docker_output=$(
"${docker_path}" inspect \
--format '{{range .Mounts}}{{if eq .Type "bind"}}{{printf "%s:%s\n" .Source .Destination}}{{end}}{{end}}' \
--format '{{range .Mounts}}{{if or (eq .Type "bind") (eq .Type "volume")}}{{printf "%s:%s\n" .Source .Destination}}{{end}}{{end}}' \
"${container_id}"
)

Expand Down
9 changes: 9 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,13 @@ for docker_version in "${docker_versions[@]}"; do
echo "Same as above but with a volume that matches the parent first"
"${docker_args[@]}" --volume "${fixtures_dir}:/folder" --volume "${fixtures_dir}/testfile:/test/testfile" --volume "${fixtures_dir}/testfile:/test/testfile2" "${image_id}" \
docker run --rm --volume /folder:/test --volume /test:/wd:ro ubuntu:latest bash -c 'grep "^test$" /wd/testfile && grep "^test$" /wd/testfile2 && grep "^test$" /wd/only-inside-container' >/dev/null

echo "With named volume"
volume_name=$(docker volume create --opt type=none --opt device="${fixtures_dir}" --opt o=bind)
trap 'docker volume rm -f "${volume_name}" >/dev/null' EXIT
# this confirms the volume works in the parent container prior to the shim
"${docker_args[@]}" --volume "${volume_name}:/wd" "${image_id}" \
grep "^test$" /wd/testfile >/dev/null
"${docker_args[@]}" --volume "${volume_name}:/wd" "${image_id}" \
docker run --rm --volume /wd:/wd ubuntu:latest grep "^test$" /wd/testfile >/dev/null
done

0 comments on commit 96bd708

Please sign in to comment.