Skip to content

Instantly share code, notes, and snippets.

@hxtree
Last active July 19, 2022 01:29
Show Gist options
  • Save hxtree/759afd49ee194abe119d8a4910502c7c to your computer and use it in GitHub Desktop.
Save hxtree/759afd49ee194abe119d8a4910502c7c to your computer and use it in GitHub Desktop.
WSL Docker Github Setup

WSL Docker Github Setup

The following details how to install Windows Subsystem Linux, Docker, and Github from the ground up on Windows 10/11.

  1. Download, run and install: https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

  2. Next, run Powershell as Administrator

    wsl --set-default-version 2
    wsl --install -d Ubuntu-20.04
    
  3. Next, run Ubuntu. Complete prompt to set user name and password.

  4. Afterwards, install Git for version control.

    sudo apt update && sudo apt install git
    git config --global user.name {USERNAME}
    git config --global user.email {EMAIL}
    
    # add ssh config
    mkdir ~/.ssh
    vim ~/.ssh/config
    Host github.com
        User {USERNAME}
        HostName github.com
        IdentityFile ~/.ssh/github.com
    
    # create ssh key
    ssh-keygen -o -f ~/.ssh/github.com
    
    # print key, use to add SSH key
    cat ~/.ssh/github.com.pub
    

    Add SSH key to https://github.com/settings/keys.

  5. Install Docker

    sudo apt install docker.io -y
    sudo visudo
    ubuntu  ALL=(ALL) NOPASSWD: /usr/bin/dockerd
    

    Configure Docker Daemon to come up automatically. This occasionally fails and sudo dockerd is required instead.

    echo '# Start Docker daemon automatically when logging in if not running.' >> ~/.bashrc
    echo 'RUNNING=`ps aux | grep dockerd | grep -v grep`' >> ~/.bashrc
    echo 'if [ -z "$RUNNING" ]; then' >> ~/.bashrc
    echo '    sudo dockerd > /dev/null 2>&1 &' >> ~/.bashrc
    echo '    disown' >> ~/.bashrc
    echo 'fi' >> ~/.bashrc
    
  6. Install Docker compose

    sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    docker-compose --version
    
    # add user to docker group
    sudo usermod -aG docker ubuntu
    

Notes:

  • wsl files are avaliable from root pc: \\wsl$\Ubuntu-20.04\home\ubuntu
  • root pc files are avaliable from wsl /mnt/c/Users/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment