code-server: Error: EACCES: permission denied

[root@localhost ~]# docker run -t -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
Unable to find image 'codercom/code-server:latest' locally
Trying to pull repository docker.io/codercom/code-server ... 
latest: Pulling from docker.io/codercom/code-server
e58ad9fd24ca: Pull complete 
0a4c669d2dea: Pull complete 
ab60767ef52b: Pull complete 
8cc3b738fbea: Pull complete 
4a49f00acafc: Pull complete 
15aff5fdd28f: Pull complete 
1a344d81f432: Pull complete 
f079d5b4236e: Pull complete 
Digest: sha256:d96615907185d67fcc75655eef3eee28399efb968aaa5e1dc319fa064db3fb08
Status: Downloaded newer image for docker.io/codercom/code-server:latest
ERROR { Error: EACCES: permission denied, mkdir '/root/project/code-server'
  [stack]: 'Error: EACCES: permission denied, mkdir \'/root/project/code-server\'',
  [message]: 'EACCES: permission denied, mkdir \'/root/project/code-server\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/root/project/code-server' }
free(): invalid pointer

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (6 by maintainers)

Commits related to this issue

Most upvoted comments

You must give permissions to the group: coder

  1. Enter the container docker exec -it app_name_1 bash
  2. Run: chown coder:coder /home/coder/project -R
  3. Try again.

I have the seme problem and nothing help. Any progress?

Ran into this problem when I was trying out code-server. Seems to me like the typical Docker problem of mismatch between host UID/GIDs and container UID/GIDs. I solved this by running the following commands instead of the one suggested in the readme:

mkdir -p ${HOME}/.local/share/code-server
docker run -it -p 127.0.0.1:8080:8080 --user $(id -u):$(id -g) -v "${HOME}/.local/share/code-server:/home/coder/.local/share/code-server" -v "$PWD:/home/coder/project" codercom/code-server:v2

In my (somewhat limited) experience, using --user $(id -u):$(id -g) seems to be the best way of handling bind mounts where files should be owned by the current user. It’s not perfect though: Any files created by the user during docker build will have a different UID and GID which could cause new problems…

EDIT: It actually works fine for me without the --user flag as long as ${HOME}/.local/share/code-server exists, but any files created inside code-server will have the UID and GID of the user inside the container which may or may not be the same as the user on the host system that is executing the docker run command.

It seems that the container tries to create a mounting point on a host system with uid 0 (root) when such a directory not exist and causing the permission error on writing after the creation.

My suggestion as a workaround is, changing owner of the problematical directory after failing to run the container, than try to run the container again.

$ docker run -it -p 127.0.0.1:8080:8080 -v "${HOME}/.local/share/code-server:/home/coder/.local/share/code-server" -v "$PWD:/home/coder/project" codercom/code-server:v2
error EACCES: permission denied, mkdir '/home/coder/.local/share/code-server/extensions'  <-- permission error occured
$ ls -al ~/.local/share/code-server
total 16
drwxr-xr-x  2 root root  4096 12월  2 07:49 .  <-- owned by root
drwx------ 30 lyle lyle 12288 12월  2 07:49 ..
$ sudo chown lyle:lyle .
total 16
drwxr-xr-x  2 lyle lyle  4096 12월  2 07:49 .  <-- owner changed
drwx------ 30 lyle lyle 12288 12월  2 07:49 ..
$ docker run -it -p 127.0.0.1:8080:8080 -v "${HOME}/.local/share/code-server:/home/coder/.local/share/code-server" -v "$PWD:/home/coder/project" codercom/code-server:v2
info  Server listening on http://0.0.0.0:8080
info    - Password is 7d1110f0ad0735563f8fd151
info      - To use your own password, set the PASSWORD environment variable
info      - To disable use `--auth none`
info    - Not serving HTTPS

Hi Guys, i had the same issue and edited the docker run string to be a different destination…

${HOME}/.local/share/code-server:/home/code/docker/test/.local/share/code-server"

The segment in bold was a seperate path I’d set up locally. Previously it was /coder/ which didn’t exist.

Don’t run code-server as root and don’t use /root directory. Use some other user and it’s home directory. If you already have stuff in root here’s how to move:

  1. Create user i.e. “server” - give it access to docker group sudo usermod -a -G docker server
  2. Folder will be automatically created /home/server , move your files there i.e. mv /root/project_folder /home/server/project_folder and transfer ownership chown server -R /home/server/project_folder
  3. Log in as the new user and run your docker(when you’re logged in as this user no need to specify user id in parameters) docker run -d --name="coder" -it -p 8080:8080 -v "/home/server:/home/coder/project" codercom/code-server

Reopening this since we haven’t slated a real fix, vetoing @nhooyr’s close.

I was also getting the same error for certain directories. However, I manually creates a ‘code-server’ directory and ran the docker commands again. It now works just fine.

[root@localhost ~]# docker run -t -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth
Unable to find image 'codercom/code-server:latest' locally
Trying to pull repository docker.io/codercom/code-server ... 
latest: Pulling from docker.io/codercom/code-server
e58ad9fd24ca: Pull complete 
0a4c669d2dea: Pull complete 
ab60767ef52b: Pull complete 
8cc3b738fbea: Pull complete 
4a49f00acafc: Pull complete 
15aff5fdd28f: Pull complete 
1a344d81f432: Pull complete 
f079d5b4236e: Pull complete 
Digest: sha256:d96615907185d67fcc75655eef3eee28399efb968aaa5e1dc319fa064db3fb08
Status: Downloaded newer image for docker.io/codercom/code-server:latest
ERROR { Error: EACCES: permission denied, mkdir '/root/project/code-server'
  [stack]: 'Error: EACCES: permission denied, mkdir \'/root/project/code-server\'',
  [message]: 'EACCES: permission denied, mkdir \'/root/project/code-server\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/root/project/code-server' }
free(): invalid pointer