Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable network access for the containers #951

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test-framework/sudo-test/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ impl Container {
pub fn new_with_hostname(image: &str, hostname: Option<&str>) -> Result<Self> {
let mut docker_run = docker_command();
docker_run.args(["run", "--detach"]);
if !crate::is_original_sudo() {
// Disable network access for the containers. This removes the overhead of setting up a
// new network namespace and associated firewall rule adjustments. We still need to keep
// network access enabled for original sudo however as it needs to be able to resolve
// it's own hostname to a fully qualified domain name, which isn't possible with
// `--net=none`.
docker_run.arg("--net=none");
}
if let Some(hostname) = hostname {
docker_run.args(["--hostname", hostname]);
}
Expand Down
Loading