Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The article mentions:

> What if that compose.yaml file is checked in as part of the project? Does the whole team have to agree on a set of port numbers to use for each project?

That's only if you choose to use hard coded values. You can use environment variables instead.

You can change `- "8000:80"` to `- "${DOCKER_WEB_PORT_FORWARD:-127.0.0.1:8000}:${PORT:-80}"` and now any developer can customize the forwarded port however they see fit in a git ignored `.env` file. This is what I've done in all of my example Docker web apps at: https://github.com/nickjj?tab=repositories&q=docker-*-exampl...

No Traefik or override file is needed, at least not for allowing a user to customize the forwarded port.

I like the override file and used it for years but I stopped using it entirely about 6 months ago. It's too much of a headache to commit a `docker-compose.override.yml.example` file to version control and then have folks copy that to a git ignored `docker-compose.override.yml` file. You end up with serious config drift, especially if you have a team with a few developers. It's been a source of so many "oh yeah, I forgot to update my real file" type of issues.

Between environment variables and Docker Compose profiles[0] you can have a single committed `docker-compose.yml` file that is usable in all environments for all users.

[0]: https://nickjanetakis.com/blog/docker-tip-94-docker-compose-...



By using the !reset tag I've tried to make use of the override file completely optional and therefore no example override file is needed.

I did also consider using environment variables instead of the override file. It's not a bad idea and perhaps gets around some of the limitations with !reset.

I still think using traefik to get names instead of a load of different port numbers is cool, though, especially if you want to share these links with others on your network. For that I think you would need the override file, or you could just commit the labels to the main file as they wouldn't cause any harm, but then you've you a load of noise that people might not care about (and what if they have their own label based tool of choice?)

Thanks for the link to your work, it looks very useful.


Note that it is no longer called docker-compose.yml, now they are just called compose.yml and compose.override.yml. Another worthy mention are profiles. You can have a dev profile in there that is configurable with environment variables.


The comment you are replying to mentions profiles (and links to their own blog about it). Do you mean the same feature or something different?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: