-
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
feature: variables for scale: id, hostname #1131
Conversation
@ioggstream Thanks! I've tested your PR. I found out that the variables only work for the I have a use case to configure a container with its "outside" URL that will be sent through a Rabbit Message. I would like to configure only the environment duplexer:
image: 'node:0.10'
command: 'node /code/bin/duplexer.js'
links:
- db
- mq
expose:
- '1968'
volumes:
- '../duplexer:/code'
environment:
- MONGO_URL=mongodb://db:27017/jobs
- RABBIT_URL=amqp://mq:5672
- OUTSIDE_URL=http://duplexer_%%id%%:1968 But at the moment I have to move this environment into the command to make it work: duplexer:
image: 'node:0.10'
command: 'bash -c "OUTSIDE_URL=http://duplexer_%%id%%:1968 node /code/bin/duplexer.js"'
links:
- db
- mq
expose:
- '1968'
volumes:
- '../duplexer:/code'
environment:
- MONGO_URL=mongodb://db:27017/jobs
- RABBIT_URL=amqp://mq:5672
# see command above - OUTSIDE_URL=http://duplexer_%%id%%:1968 What do you think? |
@stefanschererseal I think it's fine. If you look at the patch, it's very easy to enable the feature on other sections. Anyway, I think we should get it merged before doing further development...do you agree? |
I'll try to put the variables into the |
@stefanschererseal check if you can just add 'environment' to the list referenced here If that works, then we should just add proper tests. |
+1 for this enhancement |
Signed-off-by: Roberto Polli <[email protected]>
6e37b54
to
818ec8f
Compare
@aanand Do you think this feature is fine? Would you implement it in a different way? Thx for all your great work, |
I think it's interesting. It would be good to get an idea of how many people would use it. I'm not sold on the syntax, but that's a minor thing. We'd also need to think about how it would interact with environment variable resolution, were we to implement that. |
Syntax: open to your suggestions, so in case of merge the code will be ready. Environment: shouldn't be interested, but I can investigate. Link me how you expect to implement variable resolution and which are your doubts: I'll be glad to help! |
I'm looking forward to a feature like this being implemented. The syntax is a little unusual, however. I think it would be more natural to allow resolution of environment variables, and simply add some "special" variables which reflect the current container. Something like Also, I think it would make more sense to use these variables throughout the entire configuration and not just in select spots. I should also say - the only reason I really need a feature like this is because I have a situation where I'm lacking good Service Discovery. With proper SD, hostnames, container numbers, and many other variables are simply unnecessary. So, for that reason alone perhaps this feature shouldn't be implemented at all, and users should be encouraged to look at consul, etcd, registrator, interlock, etc... |
@hairyhenderson thanks for your feedback! I'll show my points: I am really interested in your feedback. Syntax: I made it weird to avoid messing with environment. I'm open to suggestions. Intended goals:
Variables for every parameter: it's ok. Service Discovery: you're right in many cases but:
Let me know if it does make sense for you + Peace, |
@ioggstream - thanks for the clarification! Good points about SD - I hadn't thought of the MySQL case (I haven't used MySQL in years ;)). From my perspective, I don't really care a lot about syntax. However, this is a pretty major feature and in the interest of new users I think this should be something unsurprising and easy to stumble on. I suppose I really have two separate issues - one is naming - I really think it should be The other issue is the syntax to surround variable names with. Barring I dunno, I'm really just throwing out ideas... But, like I said before, I really hope something like this gets implemented ;) |
nite + Peace, |
@ioggstream Sorry, I had no time to dig into the environment section yet. +1 for the suggestions from @hairyhenderson with Would love to see this to be merged soon! |
+1 |
+1 for this feature |
After some thought, I don't think this is a good idea.
|
Thanks for the PR, but... |
By the way, instead of interpolating the hostname in the command string ( |
2015-05-14 17:47 GMT+02:00 Aanand Prasad [email protected]:
This has the issue of multiplying the images. Eg. I need two different images with different entrypoints just to |
@ioggstream you don't need separate images at all, you can do this:
or
|
My use case is similar to yours. But after some thoughts I think it is bad design if the argument need to be specified in docket-compose.yml |
Thanks @ALL for your replies! 2015-05-14 18:08 GMT+02:00 Daniel Nephin [email protected]:
It causes
While for this to work I should have bash powers, eg. something clumsy
Let me know if I'm wrong... Thx again + Peace, |
I think it depends :) Can you please share your POV about it? |
@ioggstream You can also just run the Could you explain your use case? Why do you need your container's hostname to contain the scale number? |
Yep, that's depends. For example, if the argument is something like |
@aanand @cgcgbcbc before all thanks to you and the others for your time ;) Use case:
Using {{hostname}} and {{id}} in
|
@ioggstream What is your mysql cluster design? But I think you can always rely on service discovery to make things work.
You can use a mysql cluster proxy, and use the dns record for that proxy in your application server |
2015-05-18 4:30 GMT+02:00 Guang Chen [email protected]:
Instead I want them to be flexible like I was running them from command
|
I'm not familiar with database, but when you say mysql cluster, do you mean the mysql cluster with sql node, data node and management node or simply mysql master-slave replication ? |
for |
2015-05-18 14:48 GMT+02:00 Guang Chen [email protected]:
The image should let you free to use or not --server-id, --bin-log & co. I want a general docker image with no specialization, otherwise I would |
I don't quite understand why need to generate more images in this case, since arguments can be passed. Suppose there is a flag --gen-server-id, if passed, the entrypoint.sh will generate a server-id and use that, otherwise omit the --server-id parameter when starting mysqld. The only disadvantage but not really a disadvantage is that the entrypoint.sh will be more complex |
2015-05-18 16:27 GMT+02:00 Guang Chen [email protected]:
And then you have to reimplement this for every application (eg wildfly, I just want the entrypoint.sh be a proxy to mysqld/startup.sh/whatever. In whatever way you want to run mysql/wildfly/xxx (cluster, replica & co) Note then, that parameterized hostnames mimics exactly what happens with |
If this is the production case, I think a configuration delivery server is needed. |
I'm perfectly okay with compose generating the names, as long as the names don't change between restarts. What do we need to do to get that to happen? |
2015-05-20 3:46 GMT+02:00 Jason Marshall [email protected]:
If you remove them:
What do we need to do to get that to happen? I think you can't preserve hostnames between restart because random hostnames are probably unique in the sense of "temporal locality" (eg. docker ensures every hostname is unique in the moment of generation). If you re-run compose after a rm, one of your random hostname could have The only way is to pass hostnames to compose. |
To recap some of the discussion:
Since there is always a way to do this (using the unique hostname), it's unlikely we will be able to accept this PR. |
While
This might not be a problem if it weren't for that pesky UTS namespace. I could simply add a quick |
Setting the hostname to a service name will be fixed in 1.5.1 ( #2334) |
As discussed in #1131 (comment) we are not going to be able to merge this PR, so I'm going to close it. There is another proposal in #1503 that I think may provide another option to solve this problem (in addition to the existing option of using |
This patch enables parametric hostnames and commands when using
scale
avoiding all bash variables expansion issues.
From #1006
Signed-off-by: Roberto Polli [email protected]