devcontainers / devcontainers/templates

"Permission Denied Error when Running Non-Root Podman Development Container: mkdir: cannot create directory ‘/root’"

Open
#268 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Shell
Stars
1.4k
Forks
393
Avg merge
2h 3m
Merged PRs (30d)
1

Description

I find an issue with the VSCode Dev Container template image trying to create files in the `/root` directory within the container using the vscode username. Here's the error I received:

> [16535 ms] Exit code 1
[16535 ms] Start: Run in container: test -d '/vscode/vscode-server/bin/linux-x64/ea1445cc7016315d0f5728f8e8b12a45dc0a7286'
[16579 ms]
[16579 ms]
[16579 ms] Start: Run in container: mkdir -p '/root/.vscode-server/bin' && ln -snf '/vscode/vscode-server/bin/linux-x64/ea1445cc7016315d0f5728f8e8b12a45dc0a7286' '/root/.vscode-server/bin/ea1445cc7016315d0f5728f8e8b12a45dc0a7286'
[16623 ms]
[16623 ms] mkdir: cannot create directory ‘/root’: Permission denied
[16623 ms] Exit code 1
[16624 ms] Start: Run: podman rm -f 16650b67a2fdcc48a91885454e657b9caecf1c6511e7c774d8d0526108239cb9
[16627 ms] Command in container failed: mkdir -p '/root/.vscode-server/bin' && ln -snf '/vscode/vscode-server/bin/linux-x64/ea1445cc7016315d0f5728f8e8b12a45dc0a7286' '/root/.vscode-server/bin/ea1445cc7016315d0f5728f8e8b12a45dc0a7286'
[16628 ms] mkdir: cannot create directory ‘/root’: Permission denied
[16628 ms] Exit code 1

The `/root` directory has default permissions set to `700` in Ubuntu 22.04.4 LTS, which caused this error.

After modifying the `/root` directory permissions, I found that the Dev Container extension is able to create the `/root/.vscode-server` directory within the container. Everything works fine now, and I can happily use the Dev Container extension.

![image](https://github.com/devcontainers/templates/assets/17877785/249b452f-38d1-42d3-997b-2f058055c2d8)

So I want to know why this happened ?what caused this?

### Environment Information

#### VSCode Version:
- Version: 1.91.0 (system setup)
- Commit: ea1445cc7016315d0f5728f8e8b12a45dc0a7286
- Date: 2024-07-01T18:52:22.949Z
- Electron: 29.4.0
- Chromium: 122.0.6261.156
- Node.js: 20.9.0
- OS: Windows_NT x64 10.0.22631

#### Host:
- Ubuntu 22.04.4 LTS

#### Podman Version:
- Version: 3.4.4
- API Version: 3.4.4
- Go Version: go1.18.1
- Built: Thu Jan 1 00:00:00 1970
- OS/Arch: linux/amd64

#### Test Docker Templates Image Mirror Address:
- [ghcr.io/devcontainers/templates/python:3.1.0](https://github.com/devcontainers/templates/tree/main/src/python)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.