Skip to content
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

Allow compose to run arbitrary commands at the host level after or before containers are started #2012

Closed
hookenz opened this issue Sep 9, 2015 · 7 comments

Comments

@hookenz
Copy link

hookenz commented Sep 9, 2015

'command' - works inside a container composer definition currently and from what I understand overrides the default cmd

Can you also pull it back out to the top level or host level?

This would allow scenarios that currently have to be managed outside of docker-compose.
e,g,

couchbase1:
container_name: couchbase1
image: couchbase/server:community-3.0.1
volumes:
- /opt/couchbase/node1:/opt/couchbase/var
net: none

command: pipework add br1 couchbase 192.168.1.1@192.168.1.254

That would of course make command a keyword at the top level, but that's a small sacrifice and should be fairly easy to implement.

Unless someone has a better idea.

@hookenz hookenz changed the title Allow commands to be run outside of a container as well Allow compose to run arbitrary commands at the host level after or before containers are started Sep 9, 2015
@dnephin
Copy link

dnephin commented Sep 9, 2015

I don't think I understand the issue.

command is always run in a container. docker-compose is not a tool for running commands on the host.

If you need to run something on the host there are many tools to accomplish that task. Makefiles and bash scripts are probably the most common.

@hookenz
Copy link
Author

hookenz commented Sep 9, 2015

Sure, it just means I'm adding another tool to do what docker-compose could do to help set up arbitrary config... I guess the only use case I can see right now is pipework or manual configuration of the network since docker still isn't quite there yet.

@aanand
Copy link

aanand commented Sep 9, 2015

This sounds more like the "hooks" feature that people have requested in the past, e.g. #1341. The proposed functionality in #1510 is the front-runner for solving this class of problem.

@hookenz
Copy link
Author

hookenz commented Sep 9, 2015

Ahh right, that's basically what I'd like. Closing this then.

@jtmoree-github-com
Copy link

I have a use case.

In dev, I need to start a database container but not on live. In dev, the database container needs to have it's data loaded from the host AFTER IT STARTS. If I bring it up beforehand and get it ready then I have to fight the networking between the containers to work properly because docker compose is setting up a network that does not exist before running 'up'. It would be useful for compose to do everything.

Any other ideas are also appreciated.

@wh1t3h47
Copy link

It would be interesting to have it

I have a docker container that runs an X application, but I need to run like that

xhost +local:docker && docker compose up

I'd rather only run docker compose up (for sake of simplicity and easier for new people joining the project)

@davidjmemmett
Copy link

Apologies for posting on an old issue, but having such a mechanism could be useful for generating/refreshing credentials which are only exposed to the host, and need to be passed to containers using environment variables such as aws configure export-credentials --profile ... --format env-no-export

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants