Skip to content

Conversation

@cyberactive-paramount
Copy link

When using pods with external networks (such as macvlan for routable IPs), containers need to inherit the pod's network namespace rather than having their own network configuration. Previously, podman-compose always added --network=_default to container commands, which overrode podman's automatic network namespace inheritance from the pod.

This change adds a new x-podman.pod_network setting that:

  1. Specifies the network to attach to the pod during creation
  2. Skips adding --network to container commands when containers should inherit from the pod

The feature enables use cases like:

  • Macvlan networks where the pod has a routable LAN IP
  • External networks managed outside of compose
  • Containers that need to share localhost within the pod

Usage in docker-compose.yml:

x-podman:
  pod_network: my_external_network
  pod_args: "--infra=true --share=ipc,net"

services:
  myservice:
    image: myimage
    # No 'networks' or 'network_mode' - inherits from pod

The container will only inherit from pod when:

  • pod_network is configured
  • Container is assigned to a pod
  • Container has no explicit network_mode or networks configuration

When using pods with external networks (such as macvlan for routable IPs),
containers need to inherit the pod's network namespace rather than having
their own network configuration. Previously, podman-compose always added
--network=<project>_default to container commands, which overrode podman's
automatic network namespace inheritance from the pod.

This change adds a new x-podman.pod_network setting that:
1. Specifies the network to attach to the pod during creation
2. Skips adding --network to container commands when containers should
   inherit from the pod

The feature enables use cases like:
- Macvlan networks where the pod has a routable LAN IP
- External networks managed outside of compose
- Containers that need to share localhost within the pod

Usage in docker-compose.yml:
```yaml
x-podman:
  pod_network: my_external_network
  pod_args: "--infra=true --share=ipc,net"

services:
  myservice:
    image: myimage
    # No 'networks' or 'network_mode' - inherits from pod
```

The container will only inherit from pod when:
- pod_network is configured
- Container is assigned to a pod
- Container has no explicit network_mode or networks configuration

Signed-off-by: Adrian Arias <[email protected]>
@cyberactive-paramount cyberactive-paramount force-pushed the feature/pod-network-inheritance branch from d621066 to 5bd1c21 Compare December 18, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant