Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need solution for running dev container with rootless Docker #479

Open
jcr010910 opened this issue Jul 18, 2024 · 2 comments
Open

Need solution for running dev container with rootless Docker #479

jcr010910 opened this issue Jul 18, 2024 · 2 comments

Comments

@jcr010910
Copy link

Writing to the host filesystem fails unless the container is run with root privileges.

Steps to Reproduce:

  1. Set up rootless Docker environment (dockerd-rootless-setuptool.sh install)
  2. Start a development container (docker run ...)
  3. Attempt to write files from the container to the host filesystem (echo "test" > /host/path/file.txt)

Expected Behavior:
Files should be written successfully to the host filesystem without needing to run the container as root.

@timsu92
Copy link

timsu92 commented Jul 25, 2024

Did you try to alter file permissions? Like using chmod?

@samruddhikhandale
Copy link
Member

To write files from a rootless Docker container to the host filesystem, you need to ensure that the user inside the container has the necessary permissions to write to the specified directory on the host. Here are the steps to achieve this:

  • Ensure Correct User Mapping: When running Docker in rootless mode, the user inside the container is mapped to a user on the host. Ensure that the user inside the container has the same UID and GID as the user on the host who has write permissions to the target directory.
  • Set Up Permissions on the Host: Ensure that the target directory on the host has the appropriate permissions to allow writing by the user mapped from the container.
  • Run the Container with the Correct User: Use the --user flag to specify the UID and GID when running the container.

@jcr010910 Which image are you using? The images hosted from https://github.com/devcontainers/images have ^ configured to support rootless docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants