Install docker-ce in debian wsl and make it work with Windows Docker Desktop

joel
1 min readOct 23, 2019

--

  1. Install Windows Docker Desktop.
  2. Expose 2375 port on Docker settings.

For centos vm which running Docker service, add a file in /etc/docker/daemon.json

{
“hosts”: [
“tcp://0.0.0.0:2375”,
“unix:///var/run/docker.sock”
]
}

Now, if we restart docker service, it won’t work. Do the following:

Workaround by overriding the service configuration:

  1. Take a look at the current configuration:
# systemctl cat docker | grep Exec
ExecStart=/usr/bin/dockerd -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
  1. Make an override:
root@imax:~# systemctl edit docker

In the editor, add the following lines:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
  1. Take a look at the new configuration:
root@imax:~# systemctl cat docker | grep Exec
ExecStart=/usr/bin/dockerd -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
ExecStart=
ExecStart=/usr/bin/dockerd

Now, the docker service can be started with a "hosts" section in daemon.json.

So far, run systemctl start docker, all fine.

On linux docker host, we need to allow 2375 port.

sudo firewall-cmd — permanent — add-port=2375/tcp

3.Install docker in wsl debian version. Follow official instructions here.
https://docs.docker.com/v17.12/install/linux/docker-ce/debian/

4. Test it by typing this command:

docker -H tcp://0.0.0.0:2375 images

5. Add Docker host env into .bashrc or .profile in home directory.

echo “export DOCKER_HOST=‘tcp://0.0.0.0:2375’” >> ~/.bashrc

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Responses (1)

Write a response