Skip to content

Document SELinux relabelling options and add warning#832

Open
justincormack wants to merge 1 commit into
docker:masterfrom
justincormack:selinux-labelling
Open

Document SELinux relabelling options and add warning#832
justincormack wants to merge 1 commit into
docker:masterfrom
justincormack:selinux-labelling

Conversation

@justincormack
Copy link
Copy Markdown
Contributor

Make it clear what the z and Z options do, and that they
affect files on the host system.

See the discussion in moby/moby#30934
for the reasons a warning is needed.

Signed-off-by: Justin Cormack justin.cormack@docker.com

animal rave

Make it clear what the `z` and `Z` options do, and that they
affect files on the host system.

See the discussion in moby/moby#30934
for the reasons a warning is needed.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #832 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #832   +/-   ##
=======================================
  Coverage   52.96%   52.96%           
=======================================
  Files         244      244           
  Lines       15828    15828           
=======================================
  Hits         8383     8383           
  Misses       6891     6891           
  Partials      554      554

Comment thread docs/reference/run.md
only be used on directories that are intended for use by containers, and not the
host system itself. In most cases, such as shared access, it is better to label
in advance. If your container does require broader access to system directories,
then use of '--security-opt label:disable' with the 'docker run' command is a better
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this such a good thing to encourage?

Copy link
Copy Markdown
Contributor

@mdlinville mdlinville Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear we already have something about this in the docs, let me find it. Yes, here: https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label Perhaps you can just link to that instead of putting these docs here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, forgot about that; good point. @justincormack perhaps you can look at that section in the docs and see if anything is missing there? Then we can link to there

Comment thread docs/reference/run.md
only be used on directories that are intended for use by containers, and not the
host system itself. In most cases, such as shared access, it is better to label
in advance. If your container does require broader access to system directories,
then use of '--security-opt label:disable' with the 'docker run' command is a better
Copy link
Copy Markdown
Contributor

@mdlinville mdlinville Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear we already have something about this in the docs, let me find it. Yes, here: https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label Perhaps you can just link to that instead of putting these docs here.

@AkihiroSuda
Copy link
Copy Markdown
Collaborator

What's current status?

@justincormack

@AkihiroSuda
Copy link
Copy Markdown
Collaborator

What's current status?

cc @thaJeztah

Comment thread docs/reference/run.md
The `z` option will make the files available to any container, using the `s0` label,
while the `Z` option will label the files with the same label as the container, so
that they are exclusive to that container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These do more then just modify the MCS Portion of the SELinux label. They modify the entire label to either
system_u:object_r:container_file_t:s0 or system_u:object_r:svirt_lxc_net_t:s0 (On RHEL/Centos, Hopefully fixed in RHEL7.5)

Comment thread docs/reference/run.md
level system directory would result in the relabeling of those directories for use
by containers. There are some blacklisted paths, but this could cause issues such
as being unable to SSH back into a system. When using the relabel options, it should
only be used on directories that are intended for use by containers, and not the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sed s/intended/dedicated/g

Comment thread docs/reference/run.md
only be used on directories that are intended for use by containers, and not the
host system itself. In most cases, such as shared access, it is better to label
in advance. If your container does require broader access to system directories,
then use of '--security-opt label:disable' with the 'docker run' command is a better
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to give a container broad access to content in a homedirectory ar all of /var then it is better to disable SELinux protections in the container then to attempt to change the labels. Use the '--security-opt label:disable` ...

@Benehiko
Copy link
Copy Markdown
Member

Since this document already exists somewhere else as pointed out here do we want to have this or do we just close this PR? /cc @dvdksn

@thaJeztah thaJeztah added this to the 29.5.1 milestone May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants