diff --git a/lib/docker-compose/models/compose_container.rb b/lib/docker-compose/models/compose_container.rb index 0f0636d..e924606 100644 --- a/lib/docker-compose/models/compose_container.rb +++ b/lib/docker-compose/models/compose_container.rb @@ -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 = {} @@ -150,6 +150,27 @@ def prepare_volumes volumes end + # + # Prepare Hostconfig Bind mounts by converting + # relative paths into absolute paths + # + def prepare_volume_binds + 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