Skip to content
Discussion options

You must be logged in to vote

The Fix: Security Labeling with :Z

To resolve the Permission Denied error on systems with SELinux (like Fedora, RHEL, or CentOS), you must tell Docker to relabel the volume context. This triggers Docker to automatically run chcon -Rt container_file_t on the host folder, changing the files with the correct security context so the container can access them.

Option 1: In devcontainer.json

Add the ,Z flag to your workspaceMount string:

"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached,Z"

Option 2: In docker-compose.yml

Append the :Z to your volume definition:

services:
  api:
    volumes:
      - .:/workspace:cached,Z

After restarting your contai…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by stircrazyexpert101
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants