-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Running Code-Server in WSL2 #1868
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
Comments
I don't have any personal experience with autostarting services on WSL, but this looks like what you're looking for: https://superuser.com/questions/1343558/how-to-make-wsl-run-services-at-startup/1365978 I'll close the issue but feel free to continue posting here. |
How I run the
|
@iHackFX I love the detailed explanation! We just started using GitHub Discussions. Would you be able to share this on "Show and Tell" as well? I think it will help others with the same problem |
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 |
Another FYI -- I was playing around last night with WSL2 Docker Containers on Windows. It's actually really freaking easy to spin up 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. |
code-server --version
: 3.4.1I've tried to install Code-Server using the installation script and had this error:
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:
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.
The text was updated successfully, but these errors were encountered: