Code-server: Permission issue, cannot start container

Created on 15 Aug 2019  路  8Comments  路  Source: cdr/code-server

Description

Used the example to create a docker-compose but im getting permisson errors and the container wont start.

  vscode:
    image: codercom/code-server
    container_name: vscode
    ports:
      - 8443:8443
    volumes:
      - /srv/docker/:/home/coder/project
    command: code-server --no-auth --disable-telemetry
ERROR { [Error: EACCES: permission denied, mkdir '/home/coder/project/code-server']


  [stack]:


   'Error: EACCES: permission denied, mkdir \'/home/coder/project/code-server\'',


  [message]:


   'EACCES: permission denied, mkdir \'/home/coder/project/code-server\'',


  errno: -13,


  code: 'EACCES',


  syscall: 'mkdir',


  path: '/home/coder/project/code-server' }

Related Issues

question

Most helpful comment

@mkono87 @BirkhoffLee @finzzz this is expected Docker behavior. The permission is denied because when you use bind mounts (/path/on/host:/path/in/container), Docker will create that directory on both sides if both directories don't exist on either host/container and since Docker itself runs as root, it will create it as root. Since the code-server image runs as a non-priv user (coder), it can't write to that root directory created by the bind mount, hence the "permission denied."

TL;DR the fix: sudo chown -R 1000:1000 /home/coder/project in the code-server terminal

Edit: Also creating the directory on the host (chown 1000:1000) beforehand also works.

All 8 comments

What's the UID that owns /srv/docker on the host? The user in the container is UID 1000, and there's no translation to the UID on the host unfortunately.

@deansheather That folder is owned by root. I was hoping this could have been a solution to editing my docker folders for various containers easily.

Same issue here. Any workarounds?

Requesting further information. Failure to reply means it was fixed in your end and I'll close this automatically after 3 days.

Requesting further information. Failure to reply means it was fixed in your end and I'll close this automatically after 3 days.

By this weekend il give it a shot again. I'm using a standard do ker setup on Ubuntu 18.04. I just wanted to have access to all appdata without having to 777 it all.

temporary fix:

sudo chmod -R 777 /path/to/project
sudo chmod -R 777 /path/to/.local

@mkono87 @BirkhoffLee @finzzz this is expected Docker behavior. The permission is denied because when you use bind mounts (/path/on/host:/path/in/container), Docker will create that directory on both sides if both directories don't exist on either host/container and since Docker itself runs as root, it will create it as root. Since the code-server image runs as a non-priv user (coder), it can't write to that root directory created by the bind mount, hence the "permission denied."

TL;DR the fix: sudo chown -R 1000:1000 /home/coder/project in the code-server terminal

Edit: Also creating the directory on the host (chown 1000:1000) beforehand also works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tecosaur picture tecosaur  路  3Comments

infogulch picture infogulch  路  3Comments

avelino picture avelino  路  3Comments

korzq picture korzq  路  3Comments

infogulch picture infogulch  路  3Comments