Control windows docker with Windows 10 Ubuntu Linux subsystem
Windows 10 Linux subsystems are a very powerful feature and expand the capabilities for Windows based developers greatly, without the need to use VMs or dual booting. One of these is controlling your windows based docker host via your Linux subsystem.
Why?
Linux command line is much more powerful that windows standard cmd line, you can combine a number of tools using piping to perform complex operations all via cli. Many of the tutorials, guides and normal operating commands used by docker and other tools are written using Linux based command line.
1. Setup Linux Subsystem
First you need to have your linux subsystem all setup and running. here is a guide I previous wrote to do just that.
All commands below will be via your linux subsystem.
2. Updates and packages
1 |
sudo apt-get update |
1 |
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common |
3. Add Docker’s official GPG key
1 |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - |
4. Add repository
1 |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" |
5. Install docker client
1 |
sudo apt-get install docker-ce |
6. Add docker host to bash profile
This is so that you dont have to keep telling docker client how to access the docker service.
1 |
echo "export DOCKER_HOST=localhost:2375" >> ~/.bash_profile |
7. Enable exposed daemon with docker
We are almost done, now we just need to go back to our windows system and enabled exposed daemon via the docker settings.
Right click the docker icon within your task area and choose settings.
The general tab should have a “Expose daemon on tcp://localhost:2375 without TLS”, enable this option.
You should now be able to control your Windows docker service via your Linux subsystem.
Note
There is a more secure way to establish a connect between your subsystem and docker client, have a look at the following guide.