daemon: use 'private' ipc mode by default#35621
Conversation
79e72cb to
3ed3cbc
Compare
3ed3cbc to
d2a914c
Compare
|
Need to figure out why |
cbe64bf to
7870484
Compare
|
OK, I got it now why these two tests are failing! The reason is, all the mounts are now in the private namespace, except for one used for container's /dev/shm. With this patch, this last mount is gone so test is not finding anything. The solution is to check whether there are any container mounts visible from the host system after container start -- if not, skip the test. |
7870484 to
ab7aeb2
Compare
cd3f5d2 to
737176d
Compare
|
|
07cc25c to
09e427e
Compare
|
Powerpc test case failure is unrelated, nevertheless I figured it out and fixed the test case. |
|
The following failure is most probably unrelated as I am seeing it in other PRs. I'll take a look nevertheless. |
91a7089 to
0a1c4c0
Compare
|
I worry about changing the default. |
837dd0c to
aeb04a3
Compare
|
We discussed this in the maintainers meeting and it came up "well is Kubernetes depending on shared IPC" ... I believe it is and this will break them... and even if not it's a good example of how this could break people. note: I mentioned on the call maybe they are using exec but that just doesn't make any sense because they couldn't start containers with different images in the pod, which is required for the pod scenario. |
|
@kolyshkin This wasn't confusing at all. Just that it's wrong to break existing users, which is what this does. |
|
We disscused this with @thaJeztah and @cpuguy83 on maintainers meeting today. What needs to be added is:
|
|
For the API version; upcoming release will be API v1.40, so if it gets merged before that, it's gonna be |
|
I'll revisit this one once #38700 is merged. |
|
OK I just came to realization that #38700 needs to be merged into this one, for the reasons that I am too lazy to describe right now. Also that @cpuguy83 and @thaJeztah was right from the start asking to forcefully set I have also added an item into API version history explaining the new default, and a way to change it back. I think this PR is ready for prime time, aside from the fact that it currently includes #38843; I will rebase once it's merged. |
c8ae56b to
3e2748a
Compare
is a well-known flaky test (#32673), rebuilding |
|
Derek add label: rebuild/janky |
There are two if statements checking for exactly same conditions: > if hostConfig != nil && versions.LessThan(version, "1.40") Merge these. Signed-off-by: Kir Kolyshkin <[email protected]>
This changes the default ipc mode of daemon/engine to be private,
meaning the containers will not have their /dev/shm bind-mounted
from the host by default. The benefits of doing this are:
1. No leaked mounts. Eliminate a possibility to leak mounts into
other namespaces (and therefore unfortunate errors like "Unable to
remove filesystem for <ID>: remove /var/lib/docker/containers/<ID>/shm:
device or resource busy").
2. Working checkpoint/restore. Make `docker checkpoint`
not lose the contents of `/dev/shm`, but save it to
the dump, and be restored back upon `docker start --checkpoint`
(currently it is lost -- while CRIU handles tmpfs mounts,
the "shareable" mount is seen as external to container,
and thus rightfully ignored).
3. Better security. Currently any container is opened to share
its /dev/shm with any other container.
Obviously, this change will break the following usage scenario:
$ docker run -d --name donor busybox top
$ docker run --rm -it --ipc container:donor busybox sh
Error response from daemon: linux spec namespaces: can't join IPC
of container <ID>: non-shareable IPC (hint: use IpcMode:shareable
for the donor container)
The soution, as hinted by the (amended) error message, is to
explicitly enable donor sharing by using --ipc shareable:
$ docker run -d --name donor --ipc shareable busybox top
Compatibility notes:
1. This only applies to containers created _after_ this change.
Existing containers are not affected and will work fine
as their ipc mode is stored in HostConfig.
2. Old backward compatible behavior ("shareable" containers
by default) can be enabled by either using
`--default-ipc-mode shareable` daemon command line option,
or by adding a `"default-ipc-mode": "shareable"`
line in `/etc/docker/daemon.json` configuration file.
3. If an older client (API < 1.40) is used, a "shareable" container
is created. A test to check that is added.
Signed-off-by: Kir Kolyshkin <[email protected]>
|
Rebased on top of merged #38843 |
(this is a follow-up to #34087)
This changes the default ipc mode of daemon/engine to be private, meaning the containers will not have their
/dev/shmfilesystem mounted on the host and then bind-mounted from host to a container by default.The benefits of doing this are:
No leaked mounts. This eliminates a possibility to leak mounts into other namespaces (and therefore unfortunate errors like "Unable to remove filesystem for $ID: remove /var/lib/docker/containers/$ID/shm: device or resource busy").
Working checkpoint/restore. Make
docker checkpointnot lose the contents of/dev/shm, but save it to the dump, and be restored back upondocker start --checkpoint.Better security. Currently any container is opened to share its
/dev/shmwith any other container.The downside is, obviously, this change will break the following usage scenario:
The solution, as hinted by the (amended) error message, is to explicitly enable donor sharing by using
--ipc shareableoption todocker runordocker create:Compatibility notes
This only applies to containers created after this change. Existing containers are not affected and will work fine as their ipc mode is stored in
HostConfig.Old (bad, but backward-compatible) behavior (i.e. "shareable" containers by default) can be enabled by either using
--default-ipc-mode shareabledaemon command line option, or by adding a"default-ipc-mode": shareable"line indocker.jsonconfiguration file.If an older client (API < 1.40) is used, a "shareable" container is created. A test to check that is added.
An item in API version history explaining the new default, and a way to change it back, is added.
As a side effect, this PR fixes bug originally addressed in containers/create: use shareable ipc by default for older clients #38700 (that is obsoleted by this one).
- A picture of a cute animal (not mandatory but encouraged)
See also
A tiger cub from the 1984 USSR cartoon https://www.youtube.com/watch?v=0DnjD7w-2FI