Forked from strarsis/docker-on-wsl-windows-10-home-docker-toolbox.md
Created
November 3, 2017 08:35
-
-
Save kd2718/ee5e55a96d619851e55d5a17f76c2e73 to your computer and use it in GitHub Desktop.
Notes about Docker on WSL (Windows 10 Home / Docker Toolbox) (Virtualbox instead Hyper-V)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Docker on WSL (Windows 10 Home / Docker Toolbox) | |
(Virtualbox instead Hyper-V) | |
Docker on WSL communicates with Docker on Windows from Docker Toolbox. | |
Install VirtualBox and Docker Toolbox on Windows. | |
Docker on Windows uses VM for Linux based docker containers. | |
Create new docker machine (VM): | |
> docker-machine.exe create default | |
Find out (Docker daemon) IP of default docker-machine and use that IP for Docker client: | |
> docker-machine.exe ip | |
```` | |
open C:\Users\<user>\.docker\machine\machines\default\config.json: The system cannot find the file specified. | |
```` | |
If this doesn't work, remove folder in | |
C:\Users\<user>\.docker\machine\machines | |
manually. | |
Then try again: | |
> docker-machine.exe create default | |
After setting up environment v<user>ables for Docker client: | |
> docker info | |
In case of error: | |
```` | |
could not read CA certificate "/home/build/.docker/ca.pem": open /home/build/.docker/ca.pem: no such file or directory | |
```` | |
Note: | |
In Windows, docker client has to run as admin, otherwise this error will occur: | |
```` | |
open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows | |
```` | |
If already running as admin, try this fix | |
> docker-machine env | |
Copy + paste/run the printed for loop (without commenting out REM) for configuring. | |
> docker-machine ls | |
> docker-machine start default | |
Network/other issues with virtual machine | |
Open VirtualBox GUI and stop + remove the default machine manually, then try again. | |
Test: | |
> docker run hello-world | |
On WSL, install Docker CE. | |
`docker info` will result in an error (can't connect to daemon). | |
.bashrc on WSL: | |
```` | |
# Docker (Docker Toolbox on Windows) | |
export DOCKER_TLS_VERIFY=0 | |
export DOCKER_HOST=tcp://$(cd /mnt/c && docker-machine.exe ip):2376 | |
alias docker-machine="docker-machine.exe" | |
#alias docker="docker.exe" # Native docker client is used instead, less issues with environment variables | |
docker-machine.exe start default && # autostart docker-machine | |
```` | |
Edit: | |
docker-env wrapper script that translates Windows style ENV to *nix (WSL) style `export`: | |
https://gist.github.com/mmarchini/bc9df7b82127fea13612edf8bffdf96f | |
Share certs from Docker Toolbox on Windows with Docker client on WSL: | |
$ mkdir -p ~/.docker | |
$ ln -s /mnt/c/Users/<user>/.docker/machine/certs/ca.pem ~/.docker/ca.pem | |
$ ln -s /mnt/c/Users/<user>/.docker/machine/certs/ca-key.pem ~/.docker/ca-key.pem | |
$ ln -s /mnt/c/Users/<user>/.docker/machine/certs/cert.pem ~/.docker/cert.pem | |
$ ln -s /mnt/c/Users/<user>/.docker/machine/certs/key.pem ~/.docker/key.pem | |
Note: _All_ of these files have to be made available/symlinked! | |
Install docker-compose natively on WSL. | |
* There is also docker-compose shipped with Docker Toolbox (alias docker-compose to docker-compose.exe) | |
- but it may be older and not the same style as the natively installed Docker client. | |
Paths in docker-compose in Bash on Windows/WSL: | |
```` | |
ERROR: for <container> Cannot start service php: oci runtime error: container_linux.go:262: starting container process caused "chdir to cwd (\"<target container path>\") set in config.json failed: no such file or directory" | |
```` | |
See https://github.com/Microsoft/BashOnWindows/issues/1854 | |
Proposed solutions: | |
.env file with this content: | |
```` | |
COMPOSE_CONVERT_WINDOWS_PATHS=1 | |
```` | |
export as environment variable: | |
```` | |
export COMPOSE_CONVERT_WINDOWS_PATHS=1 | |
```` | |
or in .bashrc: | |
```` | |
COMPOSE_CONVERT_WINDOWS_PATHS=1 | |
```` | |
But this doesn't resolve the issue for me... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment