Fix compatibility issue with Docker Compose 2 #554
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Docker Compose project has moved from v1 to v2.
For now, it's still possible to opt-out of v2 and revert to v1 when using Docker for Mac. However this option will likely go away at some point. It's therefore a good idea to ensure GOV.UK Docker works with both versions.
As far as I can see, the only compatibility issue that existed is that the
nginx
container attaches to the 'default' network. As I understand it, the network calleddefault
is no longer implicitly created with Docker Compose v2, so it needs to be defined in the docker compose file.For more info, see: docker/compose#9015
It's not clear when this change happened as it's not documented as a known change: https://docs.docker.com/compose/compose-file/compose-versioning/
Demonstration of compatibility issue
The scripts
bin/replicate-mysql.sh
andbin/replicate-postgres.sh
both run the command:When running with Docker Compose v1, this command outputs a YAML document describing the current project config.
With Docker Compose v2, the command fails with an error:
However when the
default
network is explicitly defined in the maindocker-compose.yml
file, both v1 and v2 run correctly without error.With this change applied, I'm now able to successfully run
bin/replicate-mysql.sh
andbin/replicate-postgres.sh
regardless of the Docker Compose version I'm using.