Skip to content

Instantly share code, notes, and snippets.

@aweiteka
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save aweiteka/b847c042f1a683c5fd9b to your computer and use it in GitHub Desktop.

Select an option

Save aweiteka/b847c042f1a683c5fd9b to your computer and use it in GitHub Desktop.
Proposal: docker run from file

Use case

I am a developer...

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 am a tester / I am an ops engineer / I am an end-user

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>.

Opportunity

(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.

User Experience

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

Proposed Updates

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.

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