Skip to content

[Request]: Allow for port publishing / connectivity to container when "none" network is selected #1037

Closed

Description

@matthewcmead

Feature or enhancement request details

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?

Thanks for the consideration.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. jglogan commented on Jan 10, 2026

    @jglogan
    Contributor

    @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.

    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.

  2. JaewonHur commented on Jan 14, 2026

    @JaewonHur
    Contributor

    Let me look at it.

  3. JaewonHur commented on Jan 14, 2026

    @JaewonHur
    Contributor

    We have to options to support it.

    1. Add a feature to make host-only restricted network and allow the host and containers connect under it.
    2. 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.
  4. matthewcmead commented on Jan 17, 2026

    @matthewcmead
    Author

    We have to options to support it.

    1. Add a feature to make host-only restricted network and allow the host and containers connect under it.
    2. 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.

    Thanks for considering it.

  5. added
    facet/network
    on Jan 24, 2026
  6. added this to the 2026-01 milestone on Jan 24, 2026
  7. added 2 commits that reference this issue on Jan 27, 2026
    9d4cded
    82c9313
  8. added a commit that references this issue on Feb 4, 2026
    8b79ec5
  9. added a commit that references this issue on Feb 18, 2026
    61c0378
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

facet/network

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions