question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running Code-Server in WSL2

See original GitHub issue
  • Web Browser: Chrome in Windows 10
  • Local OS: Windows 10
  • Remote OS: Ubuntu 20.04 and WSL2
  • Remote Architecture: NA
  • code-server --version: 3.4.1

I’ve tried to install Code-Server using the installation script and had this error:

Failed to connect to bus: No such file or directory

That is related to systemd and WSL2 (WSL and WSL2 don’t support systemd, the PID 1 is Init). Then, I’ve tried the Code-Server manual installation and every time I open WSL terminal I have to run:

$ code-server
info  Using config file ~/.config/code-server/config.yaml
info  Using user-data-dir ~/.local/share/code-server
info  code-server 3.4.1 44f7c2724827e526eeaa6c2c151c520f48a61222
info  HTTP server listening on http://0.0.0.0:8001
info      - Using password from ~/.config/code-server/config.yaml
info      - To disable use `--auth none`
info    - Not serving HTTPS

Is there any option to start Code-Server when Windows/WSL starts?

Is running Code-Server in Docker inside WSL2 an option?

Any help is welcome. Regards.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
fearthecowboycommented, Oct 21, 2020

Another FYI – I was playing around last night with WSL2 Docker Containers on Windows.

It’s actually really freaking easy to spin up code-server via the container; I’m working on some simple scripting to iron out the edges and should have that ready in a couple days.

Turns out that it’s really easy to add an automatic UPNP firewall port mapping, so that it can be exposed past the NAT without having to manually configure the router firewall, and by just mapping the one port thru the host, this gets stupid kinds of simple. I’m crafting a script for this, I’ll be back in a day or two.

# Quick & Dirty powershell script to use the containter with Docker & WSL2 containers.
# Run this wherever you want the folder created and mapped to.

# create a folder in the current directory
cd (mkdir -ea 0 code-server)

# create the '.config' and 'project' folders in the current location.
mkdir -ea 0 .config,project

# reformat the current folder as a unix-style path 
$LOC = "/$(((pwd).path).substring(0,1).tolower()+((pwd).path).substring(1))" -replace '\\' ,'/' -replace ':',''

# Run the docker image, map it back to port 8080 on the host, and map the .config and project folders  
docker run -it --name code-server -p 127.0.0.1:8080:8080 -v "$LOC/.config:/home/coder/.config"  -v "$LOC/project:/home/coder/project"  codercom/code-server:latest -e PASSWORD=Hi-Mom!

I may just roll the whole thing up into an extended docker image with a few parameters.

3reactions
fearthecowboycommented, Sep 21, 2020

FYI - I have a quick & dirty write up how I did code-server on WSL2:

https://fearthecowboy.com/tutorial/2020/09/17/Code-Serrver-On-WSL.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running Code-Server in WSL2 · Issue #1868 - GitHub
# Run this wherever you want the folder created and mapped to. # create a folder in the current directory cd (mkdir -ea...
Read more >
Get started using VS Code with WSL - Microsoft Learn
Install VS Code and the WSL extension · Visit the VS Code install page and select the 32 or 64 bit installer. ·...
Read more >
Working with Visual Studio Code on Ubuntu on WSL2
The easiest way to access your Ubuntu development environment in WSL is using Visual Studio Code via the built in Remote extension.
Read more >
Using WSL 2 with Visual Studio Code
Open WSL either by launching the Windows Terminal and creating a new WSL tab or by launching the Linux distro that you installed....
Read more >
VSCode in WSL2-Ubuntu - Medium
How to setup VSCode in Ubuntu 20.04 LTS run with WSL2 on Windows 10. ... Installation of the VS Code Server component in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found