R
R
rad_li2022-02-24 10:26:11
Docker
rad_li, 2022-02-24 10:26:11

How to restart container in docker with new options?

Launched the container with the -v localfolder/:dockerfolder/ option. Now I need to mount another folder. If you stop and start the container with new parameters, then the changes made to the container before that are lost. This web application, when launched with new parameters, prompts you to start the installation again. How to restart a container with new parameters, but so that its state remains the same?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav, 2022-02-24
@rad_li

Now there is no way - nothing is saved in the container.
When building a container, plan so that mutable data resides on mounted directories or volumes.

M
Michael, 2022-02-24
@Akela_wolf

This is crooked, but you can do docker commit, which will write the state of the container to a new image: https://docs.docker.com/engine/reference/commandli...
Specifically, this will solve your problem now, but in general, such a situation that after restarting the container data disappears - this is the use of containers for other purposes. Containers are designed to be stateless, that is, to die and start at any time (let's say an orchestrator such as Kuber can start new containers and stop existing containers at any time, depending on many conditions). Therefore, it is better to redo the container according to Feng Shui.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question