1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration/container
Sebastiaan van Stijn c3d7a0c603
Fix validation of IpcMode, PidMode, UTSMode, CgroupnsMode
These HostConfig properties were not validated until the OCI spec for the container
was created, which meant that `container run` and `docker create` would accept
invalid values, and the invalid value would not be detected until `start` was
called, returning a 500 "internal server error", as well as errors from containerd
("cleanup: failed to delete container from containerd: no such container") in the
daemon logs.

As a result, a faulty container was created, and the container state remained
in the `created` state.

This patch:

- Updates `oci.WithNamespaces()` to return the correct `errdefs.InvalidParameter`
- Updates `verifyPlatformContainerSettings()` to validate these settings, so that
  an error is returned when _creating_ the container.

Before this patch:

    docker run -dit --ipc=shared --name foo busybox
    2a00d74e9fbb7960c4718def8f6c74fa8ee754030eeb93ee26a516e27d4d029f
    docker: Error response from daemon: Invalid IPC mode: shared.

    docker ps -a --filter name=foo
    CONTAINER ID   IMAGE     COMMAND   CREATED              STATUS    PORTS     NAMES
    2a00d74e9fbb   busybox   "sh"      About a minute ago   Created             foo

After this patch:

    docker run -dit --ipc=shared --name foo busybox
    docker: Error response from daemon: invalid IPC mode: shared.

     docker ps -a --filter name=foo
    CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

An integration test was added to verify the new validation, which can be run with:

    make BIND_DIR=. TEST_FILTER=TestCreateInvalidHostConfig DOCKER_GRAPHDRIVER=vfs test-integration

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-25 17:41:51 +02:00
..
attach_test.go Make it explicit raw|multiplexed stream implementation being used 2022-05-12 11:36:31 +02:00
checkpoint_test.go unused: ignore false positives 2021-06-10 13:03:32 +02:00
container_test.go runconfig: ContainerDecoder(): fix handling of invalid JSON 2022-04-11 21:44:45 +02:00
copy_test.go client: CopyToContainer(), CopyFromContainer(): remove status-code handling 2022-04-19 08:28:20 +02:00
create_test.go Fix validation of IpcMode, PidMode, UTSMode, CgroupnsMode 2022-05-25 17:41:51 +02:00
daemon_linux_test.go refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
daemon_test.go On startup, actually shutdown the container. 2020-04-13 14:20:12 -07:00
devices_windows_test.go Suport vpci-class-guid in the non-containerd backend 2022-03-27 13:26:47 +11: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 refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08: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-21 19:27:07 +00: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 #40084 from thaJeztah/hostconfig_const_cleanup 2021-08-28 00:21:31 +09:00
kill_test.go vendor: github.com/moby/sys/mount v0.3.0, mountinfo v0.5.0, signal v0.6.0, symlink v0.2.0 2021-11-19 09:56:37 +01:00
links_linux_test.go refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
logs_test.go refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
main_test.go testutil: make testing packages public 2019-09-11 07:47:23 -05:00
mounts_linux_test.go Use specific APIs for shared mount-point behaviour 2020-11-10 20:00:48 +11:00
nat_test.go refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
pause_test.go client: ContainerStop(), ContainerRestart(): support stop-signal 2022-04-20 21:29:34 +02:00
pidmode_linux_test.go rootless: support --pid=host 2021-02-01 14:55:18 +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 client: ContainerStop(), ContainerRestart(): support stop-signal 2022-04-20 21:29:34 +02:00
resize_test.go Prepare tests for Windows containerd support 2021-04-22 10:50:00 +03:00
restart_test.go Fixes #41871: Update daemon/daemon.go: resume healthcheck on restore 2021-10-07 21:23:27 +02:00
run_cgroupns_linux_test.go integration: port TestRunModePIDHost from CLI test to API test 2021-02-01 14:54:07 +09:00
run_linux_test.go daemon/linux: Set console size on creation 2022-05-19 07:57:27 +02: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 client: ContainerStop(), ContainerRestart(): support stop-signal 2022-04-20 21:29:34 +02:00
stop_test.go client: ContainerStop(), ContainerRestart(): support stop-signal 2022-04-20 21:29:34 +02:00
stop_windows_test.go client: ContainerStop(), ContainerRestart(): support stop-signal 2022-04-20 21:29:34 +02: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 client: ContainerStop(), ContainerRestart(): support stop-signal 2022-04-20 21:29:34 +02:00