Skip to content

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

Closed

Description

@miguelvelezmj25
  • 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.

Activity

  1. KaneLeung commented on Feb 27, 2021

    @KaneLeung

    same problem

  2. kdeyko commented on Apr 14, 2021

    @kdeyko

    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
    
  3. jsjoeio commented on Apr 14, 2021

    @jsjoeio
    Contributor

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

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

  4. added this to the On Deck milestone on Apr 14, 2021
  5. kdeyko commented on Apr 15, 2021

    @kdeyko

    @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?

  6. jsjoeio commented on Apr 15, 2021

    @jsjoeio
    Contributor

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

  7. kdeyko commented on Apr 15, 2021

    @kdeyko

    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

  8. jsjoeio commented on Apr 15, 2021

    @jsjoeio
    Contributor

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

  9. added
    needs-investigationThis issue needs to be further investigated
    and removed
    waiting-for-infoWaiting for more information from submitter
    on Apr 15, 2021
  10. code-asher commented on Apr 15, 2021

    @code-asher
    Member
  11. kdeyko commented on Apr 15, 2021

    @kdeyko

    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.

  12. kdeyko commented on Apr 15, 2021

    @kdeyko

    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
  13. LoongWynn commented on Apr 26, 2021

    @LoongWynn

    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
  14. kdeyko commented on Apr 26, 2021

    @kdeyko

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

  15. self-assigned this
    on Apr 26, 2021
  16. modified the milestones: On Deck, v3.9.5 on Apr 26, 2021
  17. videlanicolas commented on May 9, 2021

    @videlanicolas
    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).

  18. added a commit that references this issue on Sep 28, 2024
    33e3e03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions