This section is not strictly needed for using Docker on Windows. However, heavy users of WSL may find this convenient... after all the set up is done.
Note that if you have any symlinks in WSL, one of the following steps may render all of them inoperable and you will have to re-create those symlinks. This is due to an alteration of the WSL's directory structure.
The following steps assume that you're running Windows 10 18.03.
- Open the Docker Quickstart Terminal and run
docker-machine env
. Make a note of the value of theDOCKER_HOST
variable.
Run the following commands in order
export DOCKER_CHANNEL=edge
export DOCKER_COMPOSE_VERSION=1.21.0
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) ${DOCKER_CHANNEL}"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo usermod -aG docker $USER
sudo curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
- Close and reopen WSL
nano ~/.bashrc
and add the following 3 lines to the bottom of the file.export DOCKER_HOST=tcp://0.0.0.0:2376
- W10 Home Users: Use your docker host ip address from the previous section instead of
0.0.0.0
here
- W10 Home Users: Use your docker host ip address from the previous section instead of
export DOCKER_CERT_PATH="/c/Users/<YOUR WINDOWS USER NAME HERE>/.docker/machine/certs"
export DOCKER_TLS_VERIFY=1
Run sudo nano /etc/wsl.conf
and type the following.
[automount]
root = /
options = "metadata"
Hit ctrl-o
, save the file, ctrl-x
to exit.
Reboot Windows for the changes to fully take effect and avoid errors with the WSL within the session.
The above file sets your root directory of each hard disk to /c
or /d
instead of the WSL defaults of /mnt/c
or /mnt/d
. Docker expects the former. Hence, this breaks symlinks, and if you have any, you will need to re-link them.