Skip to content

Commit

Permalink
fix(docker-compose): compatibility with docker-compose v2 and docker …
Browse files Browse the repository at this point in the history
…>= v27 (#838)

* fix(docker-compose): compatibility with docker-compose v2 and docker >= v27
* Add compatibility with bother docker-compose v1 and v2 through the docker binary
  • Loading branch information
jankal authored Aug 3, 2024
1 parent 5471f94 commit ae67fe3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/docker-sync/docker_compose_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ def down

private

def docker_compose_legacy_binary_exists?
system('which docker-compose > /dev/null 2>&1')
end


def run!(*args)
# file_args and args should be Array of String
file_args = @files.map { |file| "--file=#{file}" }

@last_command = Command.run('docker-compose', *file_args, *args, dir: @dir).join
if docker_compose_legacy_binary_exists?
command = 'docker-compose'
command_args = file_args + args
else
command = 'docker'
command_args = ['compose'] + file_args + args
end

@last_command = Command.run(command, *command_args, dir: @dir).join
status = @last_command.status
out = @last_command.captured_output
err = @last_command.captured_error
Expand Down

0 comments on commit ae67fe3

Please sign in to comment.