You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Request]: Allow for port publishing / connectivity to container when "none" network is selected #1037
Sometimes the purpose of using --network none is to isolate the container from being able to connect to external networks while connectivity from the host to the container would be useful. Currently when using --network none, if ports are published with -p, there is no listening socket on the host and no connectivity to the container.
I'm requesting to change this to allow for host to container connectivity to work using port publishing when --network none is used.
There is a workaround for this, but it's somewhat of a hassle: --publish-socket can be used to connect a unix domain socket into the container and socat can be used on the host as well as the container to connect the published domain socket to ports on the host and in the container. Perhaps this can serve as the mechanism to accomplish the connectivity in an automated way that entirely avoids activating the network stack with host connectivity for the container?
@matthewcmead If you feel like trying a quick hack, you could change the mode of the default network to VMNET_HOST_MODE and play around with that setup. The containers on that network can talk to each other and to the host, but can't go off host.
Add a feature to make host-only restricted network and allow the host and containers connect under it.
After making container under default network, deleting gateway (i.e., ip route del default) leaves it unconnected, but still network under that subnet works. However, it's not a true isolation as the container can restore the external connection whenever it wants.
Add a feature to make host-only restricted network and allow the host and containers connect under it.
After making container under default network, deleting gateway (i.e., ip route del default) leaves it unconnected, but still network under that subnet works. However, it's not a true isolation as the container can restore the external connection whenever it wants.
I prefer #1. However, I've checked behavior with docker as well. It also does not seem to allow the port to be forwarded with "--network none" specified. I feel this would be a useful addition, particularly #1 from above, but I understand if it's something you want to avoid because it deviates from a well known existing behavior elsewhere. I can always automate around the unix domain socket instead.
Activity
jglogan commentedon Jan 10, 2026
@matthewcmead If you feel like trying a quick hack, you could change the mode of the default network to
VMNET_HOST_MODEand play around with that setup. The containers on that network can talk to each other and to the host, but can't go off host.Grab the source, and in the main branch, make the change here: https://github.com/apple/container/blob/main/Sources/Services/ContainerNetworkService/Server/ReservedVmnetNetwork.swift#L113.
Clearly it doesn't give you the container-level granularity you want, but it's what could be delivered with a relatively simple contribution.
JaewonHur commentedon Jan 14, 2026
Let me look at it.
JaewonHur commentedon Jan 14, 2026
We have to options to support it.
ip route del default) leaves it unconnected, but still network under that subnet works. However, it's not a true isolation as the container can restore the external connection whenever it wants.matthewcmead commentedon Jan 17, 2026
I prefer #1. However, I've checked behavior with docker as well. It also does not seem to allow the port to be forwarded with "--network none" specified. I feel this would be a useful addition, particularly #1 from above, but I understand if it's something you want to avoid because it deviates from a well known existing behavior elsewhere. I can always automate around the unix domain socket instead.
Thanks for considering it.
Isolated network (apple#1079)
Isolated network (apple#1079)
Squashed commit of the following:
Squashed commit of the following: