moby--moby/integration
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
..
build Merge pull request #43009 from thaJeztah/skip_TestBuildWCOWSandboxSize 2021-11-10 11:59:09 -08:00
config Add configuration validation option and tests. 2021-06-23 09:54:55 +00:00
container Fix validation of IpcMode, PidMode, UTSMode, CgroupnsMode 2022-05-25 17:41:51 +02:00
daemon daemon: separate daemon ID from trust-key 2022-05-04 20:17:18 +02:00
distribution bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
image Finish refactor of UID/GID usage to a new struct 2022-03-14 16:28:57 -04:00
internal daemon/linux: Set console size on creation 2022-05-19 07:57:27 +02:00
network api/server/httputils: add ReadJSON() utility 2022-04-11 21:37:51 +02:00
plugin api: rename volume.VolumeCreateBody to volume.CreateOptions 2022-04-28 22:39:14 +02:00
secret integration/secret: add check for empty list not producing an error 2020-04-14 18:31:36 +02:00
service Fix race in TestCreateServiceSecretFileMode, TestCreateServiceConfigFileMode 2021-10-27 10:55:54 +02:00
session bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
system api: rename volume.VolumeCreateBody to volume.CreateOptions 2022-04-28 22:39:14 +02:00
testdata/https Update test certificates 2021-05-18 09:43:21 +02:00
volume api: rename volume.VolumeCreateBody to volume.CreateOptions 2022-04-28 22:39:14 +02:00
doc.go Add canonical import comment 2018-02-05 16:51:57 -05:00