Difference between revisions of "Docker-compose"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 4: Line 4:
  
 
docker-compose up -d --force-recreate --build myservice
 
docker-compose up -d --force-recreate --build myservice
 +
 +
docker-compose restart -t 30 worker
 
```
 
```
 
- https://stackoverflow.com/questions/54656741/docker-compose-issue-restarting-single-service
 
- https://stackoverflow.com/questions/54656741/docker-compose-issue-restarting-single-service
 +
- https://stackoverflow.com/questions/31466428/how-to-restart-a-single-container-with-docker-compose
  
  

Revision as of 05:16, 26 August 2022

Recreate if not there (like after docker network prune)

docker-compose up  -d --force-recreate

docker-compose up -d --force-recreate --build myservice

docker-compose restart -t 30 worker

-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