Skip to content

Instantly share code, notes, and snippets.

@Ugarz
Last active March 22, 2023 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ugarz/2f2a4bdb724e9ae03d915d2ecc6ae661 to your computer and use it in GitHub Desktop.
Save Ugarz/2f2a4bdb724e9ae03d915d2ecc6ae661 to your computer and use it in GitHub Desktop.
Scripts to run wsl

Setup development environment with WSL (Windows Subsystem Linux)

I always used a unix environment to work and like it. I'm also a creative guy, sometimes I do graphism, design and don't like to switch OS to enjoy doing both. I heard of WSL and saw this as the forgotten messiah, so here a guide to install everything you will have to set up to enjoy both like me.

Process

Powershell

First we will need to activate the Windows Subsystem Linux (WSL).

  1. Run powershell as admin type in terminal
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  1. then reboot

Bash Ubuntu

  1. Launch windows store and download ubuntu 18 LTS
  2. Install the new windows terminal from Microsoft Store (it's free)

Here's a link This terminal is a wrapper containing all your terminals on you machine : Powershell, default term, ubuntu's terminal etc

In your Ubuntu terminal

Install git

# Update your packages and install git
sudo apt-get update -y && sudo apt-get install git

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

Install zsh (source)

# Install zsh first
sudo apt-get install zsh

Install Oh-My-Zsh (source)

# A nice minimal theme for Oh-My-Zsh : [Spaceship](https://github.com/pascaldevink/spaceship-zsh-theme)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install nvm (source)

# Download nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# Export config nvm to use it in term globally
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
# Custom config
nvm set-colors YMecg
nvm install --lts

Install Docker CE for Ubuntu (source)

Configuring Docker to map Windows Docker Daemon

According to this answer on Docker Forums you can map one daemon to another. We'll need to download Docker for windows. Yeah 2 Dockers daemons will be running on ur computer but do not fear : The windows Docker daemon will be our access to images, we will map the Ubuntu Docker daemon to the windows one. This will enable us to use only one set of images across your computer and from anywhere (windows terminal, powershell, ubuntu bash, zsh, etc). So login to the windows download page by clicking Download from docker Store.

If you do not have an account you will have to create one.

Open your Ubuntu terminal (bash or zsh, whatever), add this configuration now :

export DOCKER_HOST="tcp://0.0.0.0:2375"

Please do not forget to activate the Expose daemon on tcp://localhost:2375 without TLS. The Ubuntu Docker daemon will now know that he will have to contact the Windows docker daemon to work.

Note : if you use bash, you will have to set it in ~/.bashrc as well.

Note : You will say to me that if no TLS support, there is a potential insecure door openned. And I would say yes to this, but for me, as long as I work at home on side-projects it does not bother me. If you are looking for a solution here is a nice article uppon it

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment