-
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
onStart, onStop events for containers #74
Conversation
+1 |
+1 It would be nice to have this. You can have a look at: https://github.com/discordianfish/docker-spotter But i would rather have fig as a single tool to do this instead of having several tools... |
+1 |
-1 I think run something on host server is not good idea. If you use upstart scripts for that. something like this:
But uses some actions after build - good. |
Beside the fact that upstart is only used on ubuntu, having a hook option allows the same docker image to be used in multiple configurations without having to resort to 'magical' scripts. These scripts:
I like fig as it gives me some more control (and less command-line option to remember), but the extra wrappers just to be able to provision the same image is a bridge too far. |
+1 same here :) James Mills / prologic E: prologic@shortcircuit.net.au On Sun, Sep 28, 2014 at 4:04 PM, Koen Serry notifications@github.com
|
If these commands are required to build the image, why are they not part of the Dockerfile? I've found that in general having to run a bunch of commands on the host goes against the docker philosophy. Docker already provides a lot of ways for dealing with this type of thing. One thing I've done is to create a separate container for volumes that change between dev/prod. In your fig file you can link up to the volume containers (for dev configs, etc), and in production you either link to the host or another container to get the production configs. There are many other strategies that work with stock docker and fig that remove the need for any external scripts. So far this issue has only one example which is easily solved (without this feature), by using the hostname provided by docker links (that way the host never changes). Maybe some more concrete examples would help illustrate why this feature is necessary (or allow others to suggest a way to do it without the feature)? |
I agree, that there are a lot of disadvantages of this approach. But, more than half year my workday started with typing fig up. I can run more than one project at time (without any conflict, no more crossing port), and it's make me happy :). For now I see only two alternative ways to call those commands: docker-spotter (https://github.com/discordianfish/docker-spotter) or some custom scripts. Both are harder than fig up. Common case for running those commands are: do something on host machine, when container up (or down). For example: doing some network stuff, that require to know context information about runner container (NetworkAddress, etc). May be it will work with fig scale command (will help to configure load balancer). |
If you need to run multiple websites, also have a look at https://github.com/jwilder/nginx-proxy/ which requires (almost) no set-up. After running the nginx-proxy container, start up your containers with with a The default template used for the proxy is usable for most cases, but can be easily changed (https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl) |
As compose moves to support production environments as well as development environment, the addition of "development only" type features is going to be more difficult. There are some good suggestions in this PR for alternatives, and I think we can look to better support external tooling from compose with #1510. |
Events are being added in #2392 I've included an example of how you could implement this feature using the events command. |
…rces Avoid panic when spec file is missing sections under Resources
I use fig for running local development environment (django projects). All works fine, but after each restarting of services I need manually reconfigure hipache (because ip address of www container changed). I try to add some functionality (it's dirty, untested, just idea implementations) for run some commands on start/stop of services.
For example (fig.yml):
This options should be configure hipache on
fig up
withwww
container ip address. Commands executed on host machine. Commands executed in order (as in options). Commands can use container options (for example.NetworkSettings.IPAddress
) as in ``docker inspect`. It's work good for me. But there is a question, do fig need this option, or not. I saw those problems:fig run www python manage.py shell
, because onStart event will be executed (that broke http access to project via hipache). So I must create copy of www services (called shell) and run commands with those service.Any thoughts, need or not events option?