How can I copy a Docker container's configuration when I commit an image?
-
21-12-2019 - |
Question
Ideally everything will be sorted out with a Dockerfile and volumes, but sometimes that isn't practical or convenient.
For example, I found an image with Ghost already set up, and it seemed to work. So I added a few blog entries. Then I realized that I actually needed to modify the config.js to set up the mail.
So I stopped the container, committed, made some changes in bash, committed again, and then went to go start the container again running Ghost. But I had trouble getting it to work because the new image didn't have the configuration with the working directory and environment.
How can I copy the Docker container's configuration when I commit an image? Maybe I need to write a script that runs docker inspect
on the container, pulls the config out, and then includes that in the docker commit
command line?
Solution
This is a known issue: https://github.com/dotcloud/docker/issues/1141
The way you describe is still the best to achieve that I think, but I'd try using docker insert
and see if that yield better results.