Reputation: 12249
I want to update the docker-compose.yml
file for a service of mine to change restart: "no"
for restart: unless-stopped
.
I used restart: "no"
originally to debug the container, but now it's working I had data that I don't won't to erase; so I would like to edit the docker-compose.yml
file to keep the change reflected in it (for future reference) and apply the change.
Can I just stop the container without removing it and then apply a docker-compose up
? Or docker-compose up
is only meant for "fresh created" containers and I have to use another docker command after editing docker-compose.yml
?
Upvotes: 1
Views: 3455
Reputation: 158647
Deleting and recreating containers is extremely routine, and there are many settings you can only change by deleting and recreating a container. If nothing else you'll have to delete and recreate a container to update the image it runs on, when there is inevitably a bug fix or security update.
You should reconfigure your container to use some sort of volume, either a named volume or a bind mount, to hold your application data. Anything that's not in a volume will get lost.
For this particular change, it looks like the docker container update
command can modify the restart policy. You'll have to find the Docker name of the container from docker ps
, it will be named something like directory_service_1
. But you can't use this command to change the image, environment variables, command, port mappings, or volume mounts; changing any of these things requires deleting and recreating the container.
Upvotes: 2