Skip to content

fix(docker): support SELinux shared label, fixes #7196#7939

Merged
rfay merged 2 commits intoddev:mainfrom
stasadev:20251212_stasadev_selinux
Dec 15, 2025
Merged

fix(docker): support SELinux shared label, fixes #7196#7939
rfay merged 2 commits intoddev:mainfrom
stasadev:20251212_stasadev_selinux

Conversation

@stasadev
Copy link
Copy Markdown
Member

@stasadev stasadev commented Dec 12, 2025

The Issue

How This PR Solves The Issue

Adds SELinux shared label "z" to service volumes in docker-compose https://docs.docker.com/engine/storage/bind-mounts/#configure-the-selinux-label

Adds "-selinux" suffix to docker platform in ddev version.

Manual Testing Instructions

Using Fedora, check for enabled SELinux:

$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      35

With Docker and Fedora (docker context use default):

  1. Configure Docker to use SELinux:

    $ cat /etc/docker/daemon.json
    {
        "selinux-enabled": true
    }
  2. Restart the daemon sudo systemctl restart docker

  3. Check for docker info | grep -B5 selinux, should be here

  4. Create a directory, check permissions (user_home_t):

    $ mkdir my-project
    $ ls -ldZ my-project
    drwxr-xr-x. 1 stas stas unconfined_u:object_r:user_home_t:s0 28 Dec 12 17:30 my-project
  5. Run cd my-project && ddev config --auto && ddev start - success!

  6. Check permissions (container_file_t):

    $ ls -ldZ my-project
    drwxr-xr-x. 1 stas stas system_u:object_r:container_file_t:s0 28 Dec 12 17:30 my-project

With Podman and Fedora (docker context use podman-rootless, see ddev/ddev.com#476):

  1. Check for docker info | grep -B5 selinux, should be here by default

  2. Create a directory, check permissions (user_home_t):

    $ mkdir my-project
    $ ls -ldZ my-project
    drwxr-xr-x. 1 stas stas unconfined_u:object_r:user_home_t:s0 28 Dec 12 17:30 my-project
  3. Run cd my-project && ddev config --auto && ddev start - success!

  4. Check permissions (container_file_t):

    $ ls -ldZ my-project
    drwxr-xr-x. 1 stas stas system_u:object_r:container_file_t:s0 28 Dec 12 17:30 my-project

Automated Testing Overview

Release/Deployment Notes

@stasadev stasadev requested a review from a team as a code owner December 12, 2025 15:51
@stasadev stasadev changed the title fix(docker): support SELinux labels, fixes #7196 fix(docker): support SELinux shared label, fixes #7196 Dec 12, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 12, 2025

Copy link
Copy Markdown
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Works great, tested on same fedora with podman that was a complete failure before.

Should we show IsSELinux() in ddev version ? Probably (if on linux)

@stasadev
Copy link
Copy Markdown
Member Author

Should we show IsSELinux() in ddev version ? Probably (if on linux)

Good idea, I'll add it.

@rfay rfay merged commit f1ece02 into ddev:main Dec 15, 2025
27 of 30 checks passed
@rfay rfay deleted the 20251212_stasadev_selinux branch December 15, 2025 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants