-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 for explicit container names #652
Comments
Could you give an example what the resulting containers would be named like? Also, can you give a use case to explain when this is more helpful than renaming the service itself? No negative comments I just couldn't grasp that from your example alone :) |
Sure that's why I asked for feedback :) Okay so the container names would be automagically generated normally unless
Then service would have a name of "my_service" and appear so in a The use-case for all this is to "fig up" some pieces of infrastructure and be able to reference container names by their canonical name rather than |
Doesn't fig (currently) rely heavily on the Would that cope well with scaling? A |
With what I've done so far (minus a minor issue with Links and Volumes-From will (and do) work just fine if you explicitly give a service a "container name" via OTOH this is really meant for outside use of fig as an orchestration tool where one can |
All right then, clear :) Probably useful too to fig-up and "include" some existing containers in your fig project. So, yeah, I see some useful stuff in there, but also think containers generated with a custom name will act different than the other services. Which is fine, if you're aware of that, but does require proper documentation to explain to users. So, I guess it's up to the maintainers :) |
Cool then I'll fix up some other minor issues, write docs and submit a PR
|
Perhaps see what others think of it as well? |
Sure :) I still need to do more testing and tidying up...
|
Personally I'd like to see this. I use fig as my development environment for a number of projects, and it'd be nice to let each one of the do: db:
image: postgres:9.3.5
name: pg so they can share a database instance (and, more importantly, volume). As long as the database names don't collide, this would be lovely for me. Furthermore, it could be useful for a shared ruby gems volume, among other things. |
Glad I'm not the only one :) I'll try and clean up the patches adn submit a proper PR soon. Anyone else want this? :) |
me +1. |
+1 for explicit container names! |
+1 |
This would be good, particularly the sharing use-case. Off the top of my head I'm not sure how much of an ordeal this would be to implement, but once labels are in Docker and we're no longer relying on names (moby/moby#9882), it'll be a lot easier. |
@therealprologic i haven't tried your commits yet (propably tomorrow), but is there anything i can help you with to make it PR-ready? |
+1 |
+1 |
+1! I was trying to have one of our developers run compose and it broke because their root dir name is different than mine |
Happy to inform that support for labels (moby/moby#9882) was merged and will be included in the upcoming 1.6 release of Docker. Also, I think there are currently a number of related issues in this area (#652, #869, #941 among others); perhaps the discussion should be focussed on the global proposal #1066 (but that's just a suggestion) |
I've read and re-read the proposal but I don't understand how adding labels allows one to customize explicitly the container name? If anybody has any additional insight they'd be willing to share I'd love additional information. For me, explicit container names in docker-compose/fig are essential to using reverse proxies based on container names. |
@kcmerrill Right now, Compose uses a naming convention ( Now that labels are possible, labels can be used to "identify" the containers, without having to use a special naming. For example, by starting a container named
With those labels, compose is able to determine that the container belongs to project The name of the container is no longer relevant and can be changed/customized without problems. Also docker supports filtering based on labels, so to find all containers belonging to a project, compose can use (Note: the Hope this helps! |
Thanks for the information @thaJeztah! |
@kcmerrill wrt your reverse proxy; have a look at https://github.com/jwilder/nginx-proxy (or on the Docker Hub: https://registry.hub.docker.com/u/jwilder/nginx-proxy/) Using that image as a proxy, you can automatically configure the proxy by adding an environment variable to your containers, e.g. |
Thanks @thaJeztah for the additional information. I'll be sure to take a peek. I must have a specific use case(or doing something that drastically deviates ), so I ended up building my own tools to explicitly use container names.
|
+1 for explicit container names. Otherwise you'll end up manually building a base image before being able te reference it in Dockerfiles which are build using the 'build' command in docker-compose.yml. |
+1 |
+1 |
2 similar comments
+1 |
+1 |
+1 so that you can have a "data" compose which you rarely delete, and then services with volumes_from using container names. |
This is a very useful use case for having explicit container names. |
👍 |
Closing in favour of #1518 |
Hi, Before I submit a PR for this I wanted to gauge the reaction/feedback first.
See: https://github.com/therealprologic/fig/commit/1653955606881c9d9268cfcf8044cfde01128b1c
This adds optional explicit container names to fig. Use-case:
The text was updated successfully, but these errors were encountered: