docker / awesome-compose

Awesome Docker Compose samples
https://docs.docker.com/compose/
Creative Commons Zero v1.0 Universal
34.57k stars 6.64k forks source link

Remove container_name to allow multiple apps in parallel #310

Closed StefanScherer closed 1 year ago

StefanScherer commented 1 year ago

During a test I wanted to create a second dev environment for the react-express-mongo example, but it failed, because the container name "mongo" is already in use by a stopped other dev env.

Screenshot 2022-11-23 at 11 33 05

I suggest to remove the container_name from the Docker Compose file, because Compose automatically assigns the service name and service lookup via host names work fine. The whole app still works fine.

mikesir87 commented 1 year ago

I've been thinking for a little bit that we should have written guidelines/opinions on how the Compose files should be structured and best practices around them. The usage of the container name (or lack thereof really) should definitely be in it. I can make that part of my idea list as we're looking to help take over maintaining.

LGTM!