Running Docker On Wsl

/ Comments off

Configure Docker for Windows. First, we need to expose a port in Docker for Windows for it to work in WSL. This is how you install Docker in your WSL environment - it is taken from Docker’s installation docs. Just copy and paste basically. This is for Ubuntu 18.04. With the changes in effect, you should be able to run: docker run hello-world. And see the hello-world from Docker. This was a short post, explaining how to setup your WSL system to automatically start Docker when you open your terminal. It’s a bit of a hacky solution, but it’ll make starting the Docker daemon a bit easier. Your Windows build number: Microsoft Windows Version 10.0.19041.153 I'm running a couchbase server inside WSL2 with multiple port-forwarding: (from Windows) wsl -l -v NAME STATE VERSION. Ubuntu Running 2 (inside WSL) docker ps CO. Jun 18, 2020 Installing Docker is very straightforward. Just download the installer for Docker Desktop for Windows, execute it, and follow the wizard’s steps. Make sure that during setup the “Use the WSL 2 based engine” option is selected. In most cases, the installer will detect WSL 2 and automatically have the option selected.

This is the quickest way to install Docker on WSL and sync it with your Docker containers.

Configure Docker for Windows

First, we need to expose a port in Docker for Windows for it to work in WSL.

Install Docker

This is how you install Docker in your WSL environment - it is taken from Docker’s installation docs. Just copy and paste basically. This is for Ubuntu 18.04.

After this, close and open a new terminal, so you can run Docker without sudo.

Install Docker Compose

Running Docker On Wsl Login

Installing Docker Compose can be done via PIP or the normal apt-get way.

Add bin to your PATH

Running Docker On Wsl 1

You need to add /home/<username>/.local/bin to your PATH.

Running Docker On Wsl

Edit your ~/.profile file with nano ~/.profile and add a new line anywhere in the file. Add the text export PATH='$PATH:$HOME/.local/bin'

Run source ~/.profile to activate your new path.

Windows Wsl Docker

Confirm that it works by running echo $PATH.

Add DOCKER_HOST

You might need to export the following variable to make it work. You can write it either in ~/.zshrc or in ~/.bashrc.

Running Docker On Wsl 2020

Modify WSL configurations

Running Docker Without Wsl

If you are running Windows 10 18.03+ or newer, it might be good to make some changes. sudo nano /etc/wsl.conf to edit your configurations file.

This will allow you to work from /c instead of /mnt/c, and also fixes some of your permissions. You need to sign out of Windows to make this work.