mirror of
https://github.com/games-on-whales/LXC2Docker.git
synced 2026-10-15 12:52:04 +00:00
[PR #145] [MERGED] fix(lxc): honour Docker --network none (isolated netns, no bridge NIC) #144
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/LXC2Docker#144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/LXC2Docker/pull/145
Author: @JBailes
Created: 7/17/2026
Status: ✅ Merged
Merged: 7/17/2026
Merged by: @JBailes
Base:
main← Head:fix/network-none-isolation📝 Commits (1)
a8fca84fix(lxc): honour Docker --network none (isolated netns, no bridge NIC)📊 Changes
3 files changed (+66 additions, -0 deletions)
View changed files
📝
internal/lxc/config.go(+10 -0)📝
internal/lxc/network.go(+14 -0)📝
internal/lxc/network_test.go(+42 -0)📄 Description
Problem
A container created with
--network noneis given a routable NIC on the managed bridge instead of being isolated. InbuildItems/buildPVEItemsthe network selection is:canonicalNetworkName("none")returns"none"(only""/"default"/"bridge"map to the managed network), so a none-mode container hascfg.NetworkMode == "none"and falls through to theelse, receiving:So
--network nonesilently grants full network egress. Observed live:docker inspectreportsNetworkMode=nonewhile the container haseth0with a10.100.0.xaddress, a default route, and reaches the public internet directly (DNS +1.1.1.1:443). This breaks any caller that relies on--network nonefor isolation — e.g. a sandboxed workload whose only intended egress is a proxy.Fix
Add a
nonebranch to both builders that emits LXC's isolated-netns primitive:emptygives the container a fresh network namespace containing only loopback — no veth, no IP, no route out — which is exactly Docker's--network none. (Deliberately notlxc.net.0.type = none, which in LXC shares the host netns — the opposite of isolation.)Test
TestNetworkModeNoneIsolatesNetnsruns bothbuildItemsandbuildPVEItemswithNetworkMode: "none"and asserts the config haslxc.net.0.type = empty, no bridge link/IP/gateway, and no hostlxc.namespace.clone.go build ./...andgo test ./internal/lxc/pass (one unrelated, pre-existingTestCheckCreateDiskPressurefailure is environmental — it depends on the host's free disk vs. the test threshold and also fails on a clean checkout).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.