Docker-compose
Jump to navigation
Jump to search
Recreate if not there (like after docker network prune)
docker-compose up -d --force-recreate docker-compose up -d --force-recreate --build myservice
-V, --renew-anon-volumes Recreate anonymous volumes instead of retrieving
data from the previous containers.
Labels
It looks like you are using one of the newer versions of docker compose which tracks containers by labels assigned to them rather than by their names. That is why renaming the container didn't work. Updating labels You can check container's labels through the docker inspect command. $ docker inspect --format='{{json .Config.Labels }}' container_name The project name is the value of the 'com.docker.compose.project' label. Moving an existing container to a new project is as easy as changing the value of that label. However it is not yet supported by Docker CLI. There is an open issue requesting that feature. Workaround It still can be achieved by directly editing the configuration file of that particular container. There you will find labels currently assigned to that container. $ nano /var/lib/docker/containers/$container_id/config.v2.json Assign the new project name to the 'com.docker.compose.project' label and save the file. Next you have to restart the daemon. Otherwise the changes will not be visible to docker. $ systemctl daemon-reload