I have my app running as a container on my laptop. It works. I need to give this to QE to test but I need a reliable way to tell them how to run it. The docker run command is really complex. I want to snapshot a running (or stopped) container(s) and check it into version control.
I need a way to reliably run docker images. I want to run them exactly how the developer and QE did. I need a data structure, a file, that specifies this so I can stop the "copy+paste from README" error-prone, never-updated madness. I'll need to be able to specify or override some parameters like --name <name> or -e MYVAR=<production_var>.
(Almost?) Everything we need to exactly reproduce a container--to take a "snapshot"--is in docker inspect. We've been using this pattern in a prototype project. I shouldn't have to write a wrapper to docker so docker can run from its own metadata.
Snapshot a running or stopped container. Nothing new here.
docker inspect <container_id> >> myapp.json
Run a container from a file.
docker run [override-options] myapp.json
Run another instance of a container.
docker run --name myapp2 -p <new_port_mapping> myapp.json
Let's avoid adding yet another flag to docker run. We can determine if it's a file or image name/id based on a required .json (.yaml too?) format. Any options, commands and arguments would override the value specified in the json file.
SYNTAX
docker run [OPTIONS] IMAGE|FILENAME.json [COMMAND] [ARG...]
There's a lot that could be done here. I suggest we keep it simple for now and see how the community starts using it. We could provide a %templating% syntax to the json file. We could add flags to docker inspect to remove irrelevant values. We could export a format that's easier to edit and maintain. We have a built-in standard format in "docker inspect" so we don't have to maintain another data structure.