containers / containers/podman-compose
Issue while upgrading container images using podman-compose
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Podman compose is recreating all the container mentioned in the compose yaml even if some container image(s) are changed.
**To Reproduce**
Steps to reproduce the behavior:
compose yaml 1 ::
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.4-focal
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db_data:
If using above compose yaml , if we run podman-compose up -d , it perfectly brings up two containers.
Now , if we upgrade the image for one of the container in above yaml (let's say mariadb in above case) , compose yaml looks like ::
(version changed from 10.6.4 to 10.6.16)
compose yaml 2 ::
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.16-focal
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db_data:
Now , if we again run podman-compose up -d , it is recreating all the containers again.
**Expected behavior**
The container for which image is upgraded , only that should get recreated, and other running containers should remain as is.
**Actual behavior**
Even if , single container configuration is changed, its recreating all the containers mentioned in compose yaml.
**Output**
```
$ podman-compose version
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.1
podman-compose version 1.0.6
podman --version
podman version 4.6.1
exit code: 0
$ podman-compose up
Using compose yaml 1
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.1
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=root', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
recreating: ...
** excluding: set()
podman stop -t 10 root_wordpress_1
root_wordpress_1
exit code: 0
podman stop -t 10 root_db_1
root_db_1
exit code: 0
podman rm root_wordpress_1
root_wordpress_1
exit code: 0
podman rm root_db_1
root_db_1
exit code: 0
recreating: done
podman volume inspect root_db_data || podman volume create root_db_data
['podman', 'volume', 'inspect', 'root_db_data']
['podman', 'network', 'exists', 'root_default']
podman run --name=root_db_1 -d --label io.podman.compose.config-hash=01448acde8b2d0ac474f5d03e97bbb9e6e44ed3e2614589c4680919897d11b2b --label io.podman.compose.project=root --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@root.service --label com.docker.compose.project=root --label com.docker.compose.project.working_dir=/root --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=db -e MYSQL_ROOT_PASSWORD=somewordpress -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpress -v root_db_data:/var/lib/mysql --net root_default --network-alias db --expose 3306 --expose 33060 --restart always mariadb:10.6.4-focal --default-authentication-plugin=mysql_native_password
df48d56f29f3139ebcd119d4c1ff98a2f55ffab8650d41f093f7ee339dd4781a
exit code: 0
['podman', 'network', 'exists', 'root_default']
podman run --name=root_wordpress_1 -d --label io.podman.compose.config-hash=01448acde8b2d0ac474f5d03e97bbb9e6e44ed3e2614589c4680919897d11b2b --label io.podman.compose.project=root --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@root.service --label com.docker.compose.project=root --label com.docker.compose.project.working_dir=/root --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=wordpress -e WORDPRESS_DB_HOST=db -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -e WORDPRESS_DB_NAME=wordpress --net root_default --network-alias wordpress -p 80:80 --restart always wordpress:latest
9dee3193708a1790397f9847d0f5a1f6e20650eddb46beac41be04254086c522
exit code: 0
...
After above step, again ran with compose yaml 2 below is the output -
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.1
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=root', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
recreating: ...
** excluding: set()
podman stop -t 10 root_wordpress_1
root_wordpress_1
exit code: 0
podman stop -t 10 root_db_1
root_db_1
exit code: 0
podman rm root_wordpress_1
root_wordpress_1
exit code: 0
podman rm root_db_1
root_db_1
exit code: 0
recreating: done
podman volume inspect root_db_data || podman volume create root_db_data
['podman', 'volume', 'inspect', 'root_db_data']
['podman', 'network', 'exists', 'root_default']
podman run --name=root_db_1 -d --label io.podman.compose.config-hash=c81f4dac7559dbe342190b7d628f7b75c12351e9f605a04bfe8605883d3b50bc --label io.podman.compose.project=root --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@root.service --label com.docker.compose.project=root --label com.docker.compose.project.working_dir=/root --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=db -e MYSQL_ROOT_PASSWORD=somewordpress -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpress -v root_db_data:/var/lib/mysql --net root_default --network-alias db --expose 3306 --expose 33060 --restart always mariadb:10.6.16-focal --default-authentication-plugin=mysql_native_password
32e53f9df5b281edde3c62f29f651dffe516cd7162b5de614d699dc656c9811c
exit code: 0
['podman', 'network', 'exists', 'root_default']
podman run --name=root_wordpress_1 -d --label io.podman.compose.config-hash=c81f4dac7559dbe342190b7d628f7b75c12351e9f605a04bfe8605883d3b50bc --label io.podman.compose.project=root --label io.podman.compose.version=1.0.6 --label PODMAN_SYSTEMD_UNIT=podman-compose@root.service --label com.docker.compose.project=root --label com.docker.compose.project.working_dir=/root --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=wordpress -e WORDPRESS_DB_HOST=db -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -e WORDPRESS_DB_NAME=wordpress --net root_default --network-alias wordpress -p 80:80 --restart always wordpress:latest
a2997e634bf54f5fc05c16d4dcbb804790cefa830a1a587d6cc4b8ee11a9ad3d
exit code: 0
```
**Environment:**
- OS: RHEL 8.9
- podman version: 4.6.1
- podman compose version: 1.0.6
**Additional context**
Add any other context about the problem here.
Contributor guide
Assessment
This issue has not been assessed yet.