Description
Describe the bug
When using Podman Compose, it is not possible to update a single service (e.g., app
) without affecting dependent services (e.g., proxy
) due to strict dependency enforcement. This issue occurs when attempting to rebuild and restart a service with dependent containers, even if the service is stopped. In larger stacks with multiple interdependent services, this forces a complete stack shutdown to update a single service.
This behavior contrasts with Docker Compose, where individual services can be updated without impacting dependencies.
To Reproduce
- Setup:
- Create a directory structure:
.
|-docker-compose.yaml
|-modules
| |-app
| | |-index.html
| | |-Dockerfile
| |-proxy
| | |-Dockerfile
| | |-index.html
- Both
Dockerfile
s are identical:
FROM docker.io/nginx:alpine
COPY ./index.html /usr/share/nginx/html/index.html
- Create
modules/app/index.html
:
App Version 1
- Create
modules/proxy/index.html
:
Proxy Version 1
- Create the
docker-compose.yaml
:
version: '3.8'
services:
app:
container_name: "app"
build:
context: ./modules/app
dockerfile: Dockerfile
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
networks:
- app-net
proxy:
container_name: "proxy"
build:
context: ./modules/proxy
dockerfile: Dockerfile
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
networks:
- app-net
depends_on:
app:
condition: service_healthy
networks:
app-net:
driver: bridge
- Initial Run:
- Build and start the stack:
podman-compose build
podman-compose up -d
- Verify
app
content:
podman exec -it app sh -c "curl http://localhost"
Output should be App Version 1
- Update Attempt:
- Modify
modules/app/index.html
(you may usesed -i 's/App Version 1/App Version 2/' ./modules/service_a/index.html
):
App Version 2
- Rebuild and update
app
:
podman-compose build app && podman-compose down app && podman-compose up app -d
- This results in errors:
Error: container <app_container_id> has dependent containers which must be removed before it: <proxy_container_id>: container already exists
Error: creating container storage: the container name "app" is already in use by <app_container_id>. You have to remove that container to be able to reuse that name: that name is already in use
- Check
app
content again:
podman exec -it app sh -c "curl http://localhost"
Output: Still App Version 1
- Problem:
- The
app
container cannot be removed or recreated becauseproxy
depends on it, even whenapp
is stopped. - Running
podman-compose up -d app
restarts the old container instead of creating a new one with the updated image. - Updating
app
requires stopping and removing the entire stack, which is impractical for larger stacks.
Expected behavior
In Docker Compose, a single service can be rebuilt and restarted without affecting its dependencies using:
docker-compose up -d --force-recreate --no-deps <service>
Podman Compose should offer similar functionality, allowing individual service updates without requiring the entire stack to be taken down.
Actual behavior
Podman Compose enforces dependencies strictly, preventing the removal or recreation of a service if it has dependent containers. This makes it impossible to update a single service without stopping and removing all dependent services, leading to unnecessary downtime.
Output
podman-compose version
podman-compose version 1.1.0
podman version
Environment:
- OS: Linux / Debian 12
odman version
Client: Podman Engine
Version: 4.3.1
API Version: 4.3.1
Go Version: go1.19.8
Built: Wed Dec 31 21:00:00 1969
OS/Arch: linux/amd64
Additional context
In stacks where a service like proxy depends on multiple services (e.g., 10+ containers), updating a single service requires shutting down the entire stack. This is inefficient and causes significant operational disruption, especially for users migrating from Docker Compose.
If it is a problem with podman
and not actually with podman-compose
, then how are you guys actually updating images without destroying the entire stack? I will remove dependencies for now as a "solution"...
Is this a problem with roots in libpod
? Any workarounds?