Can I update labels on a container using docker-compose without restarting the container?
Ideal scenario: - change labels in docker-compose.yml - save docker-compose.yml - run a command to update the labels without restarting the container
Can I update labels on a container using docker-compose without restarting the container?
Ideal scenario: - change labels in docker-compose.yml - save docker-compose.yml - run a command to update the labels without restarting the container
As a general rule, changing the settings or code running inside a container involves deleting and restarting the container. This is totally normal, and docker-compose up
will do it for you when necessary. (Remember to make sure any data you care about is stored outside the container.)
At a Docker API level, there are only a limited set of things that can be changed in the Update a container call, and labels aren’t one of those. That means anything that manages a container, whether direct docker
commands or Docker Compose, must always delete and recreate a container to change its labels.