podman-compose
podman-compose copied to clipboard
Unable to start multiple containers with the same port
When attempting to start two services that both leverage the same port on a container podman-compose fails where docker-compose starts successfully.
The following is a simple compose file that demonstrates the issue:
version: "3"
services:
web1:
image: nginx
ports:
- "8080:80"
web2:
image: nginx
ports:
- "8081:80"
In docker-compose the two containers are started in a separate networking space and exposed on the host with the host port. In podman-compose it appears to create a single pod and all containers share the pods networking space.
Since default behavior in docker-compose is to not share the networking space, I would recommend that each service be created in it's own pod by default and the services only share a pod by exception.
One possible way to define this would be something like this:
version: "3"
services:
web1:
pod: "web-with-sidecar"
image: nginx
ports:
- "8080:80"
web1-sidecar:
pod: "web-with-sidecar"
image: sidecar
ports:
- "8181:8080"
web2:
image: nginx
ports:
- "8081:80"
This would allow podman-compose to maintain backwards compatibility with docker-compose and allow a new way to define pods with a shared networking layer.
dupe? https://github.com/containers/podman-compose/issues/224