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

Running docker/docker-compose - "Cannot mkdir, permission denied, EACCES" #1188

Closed
simeneriks1 opened this issue Nov 20, 2019 · 5 comments · Fixed by #1191
Closed

Running docker/docker-compose - "Cannot mkdir, permission denied, EACCES" #1188

simeneriks1 opened this issue Nov 20, 2019 · 5 comments · Fixed by #1191
Labels
bug Something isn't working

Comments

@simeneriks1
Copy link
Contributor

simeneriks1 commented Nov 20, 2019

  • code-server version: Current ":latest" tag on docker.
  • OS Version: Debian 9 running in Crostini (chrome os)

Description

I am experiencing the following error when running the provided docker command in this repo, and when trying to run from a docker-compose config.

Docker-compose

simen.eriksen@penguin:~/docker/code-server$ sudo docker-compose up --build
Building code-server
Step 1/2 : FROM codercom/code-server:latest
 ---> 5ace6cdc3088
Step 2/2 : RUN chmod 777 /home/coder/ -R
 ---> Running in 58405903a982
Removing intermediate container 58405903a982
 ---> 20ed880ececf

Successfully built 20ed880ececf
Successfully tagged code-server_code-server:latest
Recreating code-server_code-server_1 ... done
Attaching to code-server_code-server_1
code-server_1  | error EACCES: permission denied, mkdir '/home/coder/.local/share/code-server/extensions'
code-server_code-server_1 exited with code 1

Docker:

simen.eriksen@penguin:~/docker/code-server$ sudo docker run -it -p 127.0.0.1:8080:8080 -v "${HOME}/.local/share/code-serve
r:/home/coder/.local/share/code-server" -v "$PWD:/home/coder/project" codercom/code-server:v2
Unable to find image 'codercom/code-server:v2' locally
v2: Pulling from codercom/code-server
Digest: sha256:1095321ec1038acb23165dc53086b142793ddbb797bf8ee0375ddaf3d7c21a34
Status: Downloaded newer image for codercom/code-server:v2
error EACCES: permission denied, mkdir '/home/coder/.local/share/code-server/extensions'

I also tried chmod 777 -R on the home directory in the container with no luck. Not sure if it is directly related to code-server but thought it would be ok to check here

@simeneriks1 simeneriks1 added the bug Something isn't working label Nov 20, 2019
@simeneriks1
Copy link
Contributor Author

Ok so after checking a few more things with a friend of mine, it turns out that docker does the following:

  1. Mount/bind volumes as user root:root
  2. The container then tries to create a folder in the root-generated directories, as the user "coder" in the container. This returns "permission denied".

See output below:

simen.eriksen@penguin:~$ sudo 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" --entrypoint /bin/bash codercom/code-server:v2
coder@8de04bb489d6:~/project$ ls
docker
coder@8de04bb489d6:~/project$ cd 
coder@8de04bb489d6:~$ ls
project
coder@8de04bb489d6:~$ cd .local/share/
coder@8de04bb489d6:~/.local/share$ ls
code-server
coder@8de04bb489d6:~/.local/share$ ls -lshd code-server/
0 drwxr-xr-x 1 root root 12 Nov 20 13:17 code-server/
coder@8de04bb489d6:~/.local/share$ cd code-server/
coder@8de04bb489d6:~/.local/share/code-server$ ls
bar  foo
coder@8de04bb489d6:~/.local/share/code-server$ touch baz
touch: cannot touch 'baz': Permission denied
coder@8de04bb489d6:~/.local/share/code-server$ 

@jake-bladt
Copy link

Seeing the same issue. Either the one-line docker launch is wrong or it requires some better explanation.

@simeneriks1
Copy link
Contributor Author

I don't think it is something wrong with the command itself, but rather the setup of the Dockerfile or container. It seems that the container volumes are created during the container creation, while the extra directories are created on run-time. When this happens you have mismatch between the .local/share/code-server (owned by root) and the container user coder trying to create folders - which then get "permission denied".

May I know which OS/System you are running docker on?

I also tried running chown and chmod on the folders runtime with no luck solving the issue.

@InsOpDe
Copy link

InsOpDe commented Nov 26, 2019

Did you found a version that works? I get the same error for nearly all versions from latest to 1.939

@simeneriks1
Copy link
Contributor Author

I found a workaround by modifying the Dockerfile, check #1191

code-asher pushed a commit that referenced this issue Dec 5, 2019
#1188 
Fixes issue with permissions mounting in directories in the container. Folders are generated by root causing issues when the container user "coder" wants to create sub-folders. This fix solves it, at least on Crostini (ChromeOS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants