Ng2-Fun
Ng2-Fun

Reputation: 3393

How to save config file inside a running container?

I am new to docker. I want to run tinyproxy within docker. Here is the image I used to create a docker container: "https://hub.docker.com/r/dtgilles/tinyproxy/".

  1. For some unknown reason, when I mount the log file to the host machine, I can see the .conf file, but I can't see log file and the proxy server seems doesn't work. Here is the command I tried:

docker run -v $(pwd):/logs -p 8888:8888 -d --name tiny dtgilles/tinyproxy

  1. If I didn't mount the file, then every time when run a container, I need to change its config file inside container.

Does anyone has any ideas about saving the changes in container?

Upvotes: 2

Views: 2591

Answers (1)

Auzias
Auzias

Reputation: 3798

Question

How to save a change committed by/into a container?

Answer

The command docker commit creates a new image from a container's changes (from the man page).


Best Practice

You actually should not do this to save a configuration file. A Docker image is supposed to be immutable. This increases sharing, and image customization through mounted volume. What you should do is create the configuration file on the host and share it at through parameters with docker run. This is done by using the option -v|--volume. Check the man page, you'll then be able to share files (or directories) between host and containers allowing to persists the data through different runs.

Upvotes: 1

Related Questions