-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support modern docker compose #317
support modern docker compose #317
Conversation
From: https://docs.docker.com/compose/gettingstarted/ > Compose V1 no longer receives updates and will not be available in new releases of Docker Desktop after June 2023. Fixes error like: line 20: docker-compose: command not found
Possible duplicate of #316 |
Possible duplicate of #303 as well, but this PR also includes some relevant doc updates. I'd be happy to see either of those merged as an alternative, and I could follow up with the doc changes separately. |
Hi @michaelkirk is this working for you? I went to test it today and found it produced an error: docker compose version
Docker Compose version v2.19.1 STRING='docker compose'
$STRING version
zsh: command not found: docker compose The other PR seems to suffer the same issue: DOCKER_COMPOSE_COMMAND="docker compose"
function compose_exec(){ ${DOCKER_COMPOSE_COMMAND} $@; }
compose_exec version
compose_exec: command not found: docker compose The shell is expecting a single word for the |
How about this? function compose_exec(){
if ! command -v docker-compose &> /dev/null
then docker compose $@;
else docker-compose $@;
fi
} |
actually, this is probably nicer: # the 'docker compose' subcommand is now the recommended method of calling compose.
# if not available, we fallback to the legacy 'docker-compose' command.
function compose_exec(){
NATIVE_COMPOSE_VERSION=$(docker compose version 2> /dev/null || true)
if [ -z "$NATIVE_COMPOSE_VERSION" ]; then
docker-compose $@;
else
docker compose $@;
fi
} It has the advantage of not causing the process to exit if the shell is running with It works by attempting to execute I considered emitting a warning where |
Hi @michaelkirk I've pushed a commit to your branch, could you please test it and let me know if it's good to merge? |
Yes, I've been using this code. The error you note seems to be a difference between bash and zsh. Note that I can indeed reproduce the error you encountered if I change the script to instead run with zsh. In any case, I'm fine with the version you have pushed as well. Thanks for reviewing! |
Here's the reason for this change 🚀
Fixes error like:
From: https://docs.docker.com/compose/gettingstarted/
Here's what actually got changed 👏
compose_exec
now first triesdocker compose
before falling back to docker-compose`Alternatively we could just drop docker-compose (v1) support. I confess that I didn't fully test the fallback behavior anyway, and apparently it's no longer supported by docker.
Here's how others can test the changes 👀
Run through any of the example projects that utilize a variety of docker compose commands, e.g. portland-metro
closes #303