Difference between revisions of "Docker-compose"

From UVOO Tech Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
 +
# Install from Github Releases
 +
```
 +
version="2.29.2"
 +
curl -LO https://github.com/docker/compose/releases/download/v${version}/docker-compose-linux-x86_64
 +
chmod +x docker-compose-linux-x86_64
 +
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
 +
docker-compose -v
 +
```
 +
 +
 
Recreate if not there (like after docker network prune)
 
Recreate if not there (like after docker network prune)
 
```
 
```

Latest revision as of 19:31, 7 September 2024

Install from Github Releases

version="2.29.2"
curl -LO https://github.com/docker/compose/releases/download/v${version}/docker-compose-linux-x86_64
chmod +x docker-compose-linux-x86_64
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
docker-compose -v 

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

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