Skip to content

Cannot start stopped docker container, user 'coder' does not exist #2767

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

Closed
miguelvelezmj25 opened this issue Feb 25, 2021 · 13 comments · Fixed by #3330
Closed

Cannot start stopped docker container, user 'coder' does not exist #2767

miguelvelezmj25 opened this issue Feb 25, 2021 · 13 comments · Fixed by #3330
Assignees
Labels
bug Something isn't working
Milestone

Comments

@miguelvelezmj25
Copy link

  • Web Browser:
  • Local OS: MacOS
  • Remote OS: Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-123-generic x86_64)
  • Remote Architecture:
  • code-server --version: 3.9.0

I set up code-server with Docker as indicated in https://hub.docker.com/r/codercom/code-server

mkdir -p ~/.config
docker run -it --name code-server -p 127.0.0.1:8080:8080 \
  -v "$HOME/.config:/home/coder/.config" \
  -v "$PWD:/home/coder/project" \
  -u "$(id -u):$(id -g)" \
  -e "DOCKER_USER=$USER" \
  codercom/code-server:latest

The initial run works perfectly. I then stop the container using ctrl+c. When I try to start the container again using docker start code-server the container stops immediately. Running docker logs code-server outputs:

[2021-02-25T14:46:34.514Z] info  code-server 3.9.0 fc6d123da59a4e5a675ac8e080f66e032ba01a1b
[2021-02-25T14:46:34.516Z] info  Using user-data-dir ~/.local/share/code-server
[2021-02-25T14:46:34.537Z] info  Using config file ~/.config/code-server/config.yaml
[2021-02-25T14:46:34.538Z] info  HTTP server listening on http://0.0.0.0:8080 
[2021-02-25T14:46:34.538Z] info    - Authentication is enabled
[2021-02-25T14:46:34.538Z] info      - Using password from ~/.config/code-server/config.yaml
[2021-02-25T14:46:34.538Z] info    - Not serving HTTPS 
^Cusermod: user 'coder' does not exist

This issue seems to be related to #2267, but I am still getting the user error message.

@KaneLeung
Copy link

same problem

@code-asher code-asher added the bug Something isn't working label Mar 1, 2021
@kdeyko
Copy link

kdeyko commented Apr 14, 2021

Having the same issue on code-server v3.9.3.
Here is the extract from my compose file:

  vscode:
    container_name: vscode
    image: codercom/code-server:3.9.3
    environment:
    - DOCKER_USER=kdeyko
    - TZ=Europe/Moscow
    - PASSWORD=supersecretpassword
    volumes:
    - /volume1/docker:/home/coder/project
    - /volume1/docker/vscode:/home/coder/.config
    user: "0:0"
    restart: always
    ports:
    - 8443:8080

@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 14, 2021

@kdeyko would be happy to look into this to help.

Is there any chance you could provide repro steps using this template?

@jsjoeio jsjoeio added the waiting-for-info Waiting for more information from submitter label Apr 14, 2021
@jsjoeio jsjoeio added this to the On Deck milestone Apr 14, 2021
@kdeyko
Copy link

kdeyko commented Apr 15, 2021

@jsjoeio thanks for your reply!
Would you like me to create a new bug report via this template, or keep it in scope of this issue?

@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 15, 2021

Feel free to do it here (thank you for asking!).

@kdeyko
Copy link

kdeyko commented Apr 15, 2021

OS/Web Information

  • Web Browser: Safari 14.0.3 (though it doesn't matter)
  • Local OS: macOS Catalina 10.15.7 (though it doesn't matter)
  • Remote OS: Synology DSM 6.2.3 (Well, XPEnology, actually, but it should not matter).
$ uname -a
Linux cube 3.10.105 #25426 SMP Tue May 12 04:53:17 CST 2020 x86_64 GNU/Linux synology_broadwell_3617xs

$ docker --version
Docker version 18.09.8, build bfed4f5
  • Remote Architecture: amd64
  • code-server --version: 3.9.3 (docker image)

Steps to Reproduce

  1. Create docker-compose.yaml file with the following contents:
version: '3.7'
services:

  vscode:
    container_name: vscode
    image: codercom/code-server:3.9.3
    environment:
    - DOCKER_USER=kdeyko
    - LOG_LEVEL=trace
    - TZ=Europe/Moscow
    - PASSWORD=supersecretpassword
    user: "0:0"
    restart: always
    ports:
    - 8444:8080
  1. Run the following command (my user is kdeyko, this is reflected in the docker-compose.yaml file above):
$ docker-compose up -d
# Similar output should appear:
# Creating network "vscode_default" with the default driver
# Creating vscode ... done
  1. [Optional, since the bug reproduces even without it] Check that code-server opens in the browser:

Screenshot 2021-04-16 at 00 00 16

  1. Restart the container
$ docker restart vscode
  1. Try opening code-server in browser or check docker logs.

Expected

Code-server should work in browser.

Actual

Code-server cannot be opened in browser.
Screenshot 2021-04-16 at 00 10 10

Curl shows "Connection refused" error:

$ curl http://localhost:8444
curl: (7) Failed to connect to localhost port 8444: Connection refused

Container logs are full of usermod: user 'coder' does not exist messages:

$ docker logs vscode
[2021-04-15T21:08:54.806Z] debug parsed command line {"args":{"_":["."],"bind-addr":"0.0.0.0:8080"}}
[2021-04-15T21:08:54.813Z] info  Wrote default config file to ~/.config/code-server/config.yaml
[2021-04-15T21:08:54.816Z] debug parsed command line {"args":{"_":[],"bind-addr":"127.0.0.1:8080","auth":"password"}}
[2021-04-15T21:08:54.823Z] debug parent:28 spawned inner process 46
[2021-04-15T21:08:55.045Z] trace parent:28 got message {"message":{"type":"handshake"}}
[2021-04-15T21:08:55.047Z] trace child:46 got message {"message":{"type":"handshake","args":{"_":["."],"bind-addr":"0.0.0.0:8080","auth":"password","password":"supersecretpassword","config":"/root/.config/code-server/config.yaml","user-data-dir":"/root/.local/share/code-server","extensions-dir":"/root/.local/share/code-server/extensions","log":"trace","verbose":true,"host":"0.0.0.0","port":8080,"proxy-domain":[],"usingEnvPassword":true,"usingEnvHashedPassword":false}}}
[2021-04-15T21:08:55.048Z] info  code-server 3.9.3 fe2dc2deb08e378069891b622bb62ad1d261d1b1
[2021-04-15T21:08:55.048Z] info  Using user-data-dir ~/.local/share/code-server
[2021-04-15T21:08:55.049Z] trace Using extensions-dir ~/.local/share/code-server/extensions
[2021-04-15T21:08:55.057Z] info  Using config file ~/.config/code-server/config.yaml
[2021-04-15T21:08:55.057Z] info  HTTP server listening on http://0.0.0.0:8080
[2021-04-15T21:08:55.057Z] info    - Authentication is enabled
[2021-04-15T21:08:55.057Z] info      - Using password from $PASSWORD
[2021-04-15T21:08:55.057Z] info    - Not serving HTTPS
usermod: user 'coder' does not exist
usermod: user 'coder' does not exist
usermod: user 'coder' does not exist
usermod: user 'coder' does not exist
usermod: user 'coder' does not exist
usermod: user 'coder' does not exist
usermod: user 'coder' does not exist

Notes

This issue can be reproduced in VS Code: I don't think so

@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 15, 2021

This is super thorough and will be a great start for figuring out this issue. Thanks @kdeyko ♥️

@jsjoeio jsjoeio added needs-investigation This issue needs to be further investigated and removed waiting-for-info Waiting for more information from submitter labels Apr 15, 2021
@code-asher
Copy link
Member

Must be:

https://github.com/cdr/code-server/blob/e9985bd658ac42c5bef38553b3e83fdb1e459be3/ci/release-image/entrypoint.sh#L8-L12

I guess USER must get set back to coder when the container restarts?

@kdeyko
Copy link

kdeyko commented Apr 15, 2021

Just in case: I hope I understand the terms “Local OS” and “Remote OS” correctly - for “Remote OS” I mean the one on which I run the docker container.

@kdeyko
Copy link

kdeyko commented Apr 15, 2021

Also I noticed that after step 4 (restarting) the container gets continuously restarted:

$ docker ps | grep vscode
982bdbc168bf        codercom/code-server:3.9.3              "/usr/bin/entrypoint…"   About a minute ago   Restarting (6) 7 seconds ago                                                    vscode

$ date
Fri Apr 16 00:48:17 MSK 2021

$ docker ps | grep vscode
982bdbc168bf        codercom/code-server:3.9.3              "/usr/bin/entrypoint…"   About a minute ago   Restarting (6) 19 seconds ago                                                    vscode

$ date
Fri Apr 16 00:48:27 MSK 2021

$ docker ps | grep vscode
982bdbc168bf        codercom/code-server:3.9.3              "/usr/bin/entrypoint…"   About a minute ago   Restarting (6) 2 seconds ago                                                    vscode

@LoongWynn
Copy link

I found that if you do not specify users, you can successfully restart it.
You can run it with args written below until the bug is fixed.

docker run -d --name code-server -p 0.0.0.0:9000:8080 \
  -v "$HOME/.config:/home/coder/.config" \
  -v "$PWD:/home/coder/project" \
  codercom/code-server:latest

@kdeyko
Copy link

kdeyko commented Apr 26, 2021

@HanyuuLu, thanks, it worked! Though I still needed to use user: "0:0" in my compose file.

@code-asher code-asher self-assigned this Apr 26, 2021
@code-asher code-asher modified the milestones: On Deck, v3.9.5 Apr 26, 2021
@code-asher code-asher removed the needs-investigation This issue needs to be further investigated label Apr 26, 2021
@videlanicolas
Copy link
Contributor

I guess what we really want to check in that if statement is that the current user (as returned by id -u -n) is different from $DOCKER_USER?

sudo usermod --login "$DOCKER_USER" coder and sudo groupmod -n "$DOCKER_USER" coder will persist across restarts because it's modifying the container's disk. USER="$DOCKER_USER" will not survive a reset because environment variables will have whatever they have at the last command of Dockerfile (with the exemption of ENTRYPOINT).

xfl12345 added a commit to xfl12345/code-server that referenced this issue Sep 28, 2024
@xfl12345 xfl12345 mentioned this issue Sep 28, 2024
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.

7 participants