In addition to the answer provided by @Ben Whaley, I personally suggest you use the Docker APIs. . To use the Docker APIs, you need to configure the docker daemon port, and the procedure here is to configure the docker daemon port
Allows you to start the container using the base Ubuntu Image and create a folder inside the container :
#docker run -it ubuntu:14.04 /bin/bash root@58246867493d :/
Outbound container status:
JSON file, which is the input for fixing the container:
#cat container_create.json { "AttachStdin": true, "AttachStdout": true, "AttachStderr": true, "ExposedPorts": { "property1": {}, "property2": {} }, "Tty": true, "OpenStdin": true, "StdinOnce": true, "Cmd": null, "Image": "ubuntu:14.04", "Volumes": { "additionalProperties": {} }, "Labels": { "property1": "string", "property2": "string" } }
Container commit API
# curl -X POST http://127.0.0.1:6000/commit?container=58246867493d\&repo=ubuntu\&tag=15.0 -d @container_create.json --header "Content-Type: application/json" | jq . % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 593 100 81 100 512 175 1106 --:--:-- --:--:-- --:--:-- 1108 { "Id": "sha256:acac1f3733b2240b01e335642d2867585e5933b18de2264315f9b07814de113a" }
The identifier that is generated is the new Image Identifier that is created from the container commit.
Get docker images
# docker images REPOSITORY TAG IMAGE ID CREATED SIZE **ubuntu 15.0 acac1f3733b2 10 seconds ago 188MB** ubuntu 14.04 132b7427a3b4 10 hours ago 188MB
Start a new imaging to see the changes made to the previous container.
# docker run -it ubuntu:15.0 /bin/bash root@3a48af5eaec9 :/
To create an image from a Docker file, how to create an image using the docker API
For more information on docker APIs , here.