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

Add "docker run" output option #53

Closed
TylerRick opened this issue Jun 8, 2016 · 8 comments
Closed

Add "docker run" output option #53

TylerRick opened this issue Jun 8, 2016 · 8 comments

Comments

@TylerRick
Copy link

I didn't see this listed as one of the output options, so I'd like to request this feature:

Sometimes it can be useful to be able to run a docker run command that is equivalent to you docker-compose.yml. So the environment section would be converted to --env options, etc.

@micahhausler
Copy link
Owner

There is a Systemd output format which does this but wraps it in systemd unit syntax. Would that suit what you are looking for?

Example:
compose becomes systemd

@TylerRick
Copy link
Author

TylerRick commented Jun 8, 2016

That's great, thanks! None of the listed output options sounded like what I was looking for, but (at least for now) I can easily just use the systemd output and extract the docker run command out of the ExecStart.

I would recommend:

  1. adding an example output from cat docker-compose.yml | container-transform --output-type systemd to the Readme (like it already has for cat docker-compose.yml | container-transform -v, though it's not clear which output format that example uses?) so that people like me who stumble upon your project can see at a glance that it can output in this format and evaluate whether that's what they need or not (and so that if they search the page for "docker run" they'll see how it ends up converting to docker run command)
  2. adding an additional docker output type that simply gives the docker run command that you could exec directly if that's all one needed

@TylerRick
Copy link
Author

Ack, you're going to tell me that there's not a one-to-one mapping between a docker-compose.yml file and a docker run command — I see now from the systemd output from my own docker-compose.yml file that it in fact generates docker run command for each service (and of course, it would).

So I guess what I would love to see is an optional option for specifying which service you want the output for. So if you want the docker run command for the db service, you might run something like cat docker-compose.yml | container-transform --output-type=docker-run --service=db.

Or if that option were omitted, it could concatenate together the docker run commands for each service, such that evaluating its output (as a shell script) would start up containers for all of those services (equivalent to a docker-compose up (or maybe a docker-compose up -d))...

@micahhausler
Copy link
Owner

A docker run output format would be really easy to implement, and it's a good idea to add more examples in the README.

I'll have to think about the --service=<service> idea. There's a number of edge cases that it brings up (specifying a service that isn't in the file, or specifying one that is and one that isn't, etc.) and I'd like to keep things as simple as possible. My inclination is just to say "only include the services you want in your input", especially since the tool doesn't generate perfect output and is really just meant to be a starting point.

@TylerRick
Copy link
Author

TylerRick commented Jun 10, 2016

I can understand the desire to keep things simple and the "only include the services you want in your input" viewpoint. Though I would think most people would prefer to leave their nice docker-compose.yml intact and not have to modify it just to select a service (I'm thinking of how docker-compose itself lets you list service(s) you want to run against for its up, run, stop, rm, etc. subcommands)... but I could easily grep the output for the line containing the name of the service I wanted, so it's no big deal for me.

Anyway, for now I'm just glad that there's a tool at all that I can use for this if needed...

I actually would have expected to be able to get the docker run command from docker-compose itself (.... since doesn't it ultimately end up executing such a command internally? or maybe it uses an API other than CLI...) It would be nice if they had something like a docker-compose --output-cli-commands [SERVICE...] option built in to parallel their existing docker-compose up [SERVICE...] subcommands...

Or from docker itself... (Like docker inspect but output a CLI command to closely recreate such a container again...)

@ozbillwang
Copy link

ozbillwang commented Jul 28, 2016

I like this idea as well, hope have more examples on how to get it.

@micahhausler
Copy link
Owner

@TylerRick Check out https://github.com/micahhausler/container-tx and let me know if that works for you

@TylerRick
Copy link
Author

(Sorry for not noticing this and responding sooner.)

Yes! That looks like exactly what I was wanting. Thanks, @micahhausler! Now just trying to build it...

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

No branches or pull requests

3 participants