moby--moby/integration/container
Sebastiaan van Stijn 660b9962e4
daemon.WithCommonOptions() fix detection of user-namespaces
Commit dae652e2e5 added support for non-privileged
containers to use ICMP_PROTO (used for `ping`). This option cannot be set for
containers that have user-namespaces enabled.

However, the detection looks to be incorrect; HostConfig.UsernsMode was added
in 6993e891d1 / ee2183881b,
and the property only has meaning if the daemon is running with user namespaces
enabled. In other situations, the property has no meaning.
As a result of the above, the sysctl would only be set for containers running
with UsernsMode=host on a daemon running with user-namespaces enabled.

This patch adds a check if the daemon has user-namespaces enabled (RemappedRoot
having a non-empty value), or if the daemon is running inside a user namespace
(e.g. rootless mode) to fix the detection.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a826ca3aef)

---
The cherry-pick was almost clean but `userns.RunningInUserNS()` -> `sys.RunningInUserNS()`.

Fix docker/buildx issue 561
---

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-15 18:20:07 +09:00
..
checkpoint_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
container_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
copy_test.go Windows: Enable more integration tests 2020-09-20 22:09:27 +03:00
create_test.go Don't set default platform on container create 2020-10-20 20:17:23 +00:00
daemon_linux_test.go Make test work with rootless mode 2021-02-03 13:54:09 +01:00
daemon_test.go On startup, actually shutdown the container. 2020-04-13 14:20:12 -07:00
diff_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
exec_test.go Windows: Enable more integration tests 2020-09-20 22:09:27 +03:00
export_test.go Using test names instead of hardcoded ones in integration/container directory 2020-05-18 16:37:04 +01:00
health_test.go Fix racey TestHealthKillContainer 2021-10-22 09:30:08 +02:00
inspect_test.go Using test names instead of hardcoded ones in integration/container directory 2020-05-18 16:37:04 +01:00
ipcmode_linux_test.go Merge pull request #40725 from cpuguy83/check_img_platform 2020-05-21 11:33:27 -07:00
kill_test.go TestInspectOomKilledTrue: skip on cgroup v2 2021-02-16 09:22:27 +01:00
links_linux_test.go hack: support $DOCKER_ROOTLESS for testing rootless 2020-03-10 05:49:45 +09:00
logs_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
main_test.go testutil: make testing packages public 2019-09-11 07:47:23 -05:00
mounts_linux_test.go Rewrite VolumesMountedAsShared/Slave as Integration tests 2020-11-08 23:15:15 +11:00
nat_test.go integration: update getExternalAddress to prefer IPv4 2021-03-24 22:04:08 +01:00
pause_test.go hack: support $DOCKER_ROOTLESS for testing rootless 2020-03-10 05:49:45 +09:00
ps_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
remove_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
rename_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
resize_test.go Windows: Enable more integration tests 2020-09-20 22:09:27 +03:00
restart_test.go Merge pull request #40725 from cpuguy83/check_img_platform 2020-05-21 11:33:27 -07:00
run_cgroupns_linux_test.go TestCgroupNamespacesRunOlderClient: support cgroup v2 2021-02-02 14:34:08 +09:00
run_linux_test.go daemon.WithCommonOptions() fix detection of user-namespaces 2021-12-15 18:20:07 +09:00
stats_test.go Merge pull request #40478 from cpuguy83/dont-prime-the-stats 2020-04-16 20:57:06 +02:00
stop_linux_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
stop_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
stop_windows_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
update_linux_test.go test-integration: support cgroup2 2020-06-22 14:17:45 +09:00
update_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
wait_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00