nexdrew / rekcod

docker inspect :mag: → docker run :runner:
ISC License
371 stars 32 forks source link

Also create docker-compose.yml? #48

Open d33tah opened 5 years ago

d33tah commented 5 years ago

I love this project! Hadn't actually tried out the commands it generates yet, but if it works as expected it'll be a life-saver for me. I have a question though - would it be within the project's scope to also generate docker-compose.yml files? The use case is about being able to migrate small-scale Docker hosts by just dumping the configuration and running it on a different host.

nexdrew commented 5 years ago

@d33tah Hi 👋 and thanks!

Building in the option to generate YAML output for docker-compose is an interesting idea. I'm not quite sure how much work it will be, but I definitely think it's doable.

Shooting from the hip, I would probably augment the "run object" returned for each container in index.js to include a new property, let's say compose, which would represent an entry for that container in a docker-compose.yml file. I'd probably just create a new function, similar to toRunCommand, that builds the compose object from the inspect object, basically doing the property conversion two different times in two different ways. Then I'd also need a way for the CLI to conditionally output those objects as YAML (though I guess it could just output JSON since YAML is supposed to be a superset of JSON).

Hmm 🤔 I'll give it some more thought. Thanks for the suggestion!

frankhommers commented 3 years ago

What I do manually, but what probably can be done automatic is drop the output in: https://www.composerize.com/

The sources of that are here: https://github.com/magicmark/composerize