Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lib/docker-compose/models/compose_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def prepare_container
port_bindings = prepare_port_bindings
links = prepare_links
volumes = prepare_volumes
volume_binds = @attributes[:volumes] && @attributes[:volumes].reject { |volume| volume.split(':').one? }
volume_binds = prepare_volume_binds

# Exposed ports are port bindings with an empty hash as value
exposed_ports = {}
Expand Down Expand Up @@ -150,6 +150,27 @@ def prepare_volumes
volumes
end

#
# Prepare Hostconfig Bind mounts by converting
# relative paths into absolute paths
#
def prepare_volume_binds
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add/adjust the specs to cover this fix?
Since the tests are passing without this fix, seems like we have an uncovered case.

return if @attributes[:volumes].nil?

binds = @attributes[:volumes].reject { |volume| volume.split(':').one? }

# Convert relative paths to absolute paths
binds.map do |bind|
bind.split(':').map do |path|
if ! path.start_with? '/' and ! ['rw','ro'].include? path
File.expand_path(path)
else
path
end
end.join(':')
end
end

#
# Process each port entry in docker compose file and
# create structure recognized by docker client
Expand Down