2

If i want to use docker from WSL in windows 10, Doing the following will do the trick. I should expose the docker daemon on tcp://localhost:2375 without TLS in the general settings of 'docker for windows'. This is accomplished via the screen:

enter image description here

Then i should to set a environment variable in WSL as:

echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc

Can i use any command to expose the daemon? I mean, is there any way to do this other than enabling the option via settings GUI of docker?

It will be great to also know about the solution to share the drives using commands.

AnjK
  • 2,887
  • 7
  • 37
  • 64

2 Answers2

1

Yes, you can configure the docker service via its config file at C:\ProgramData\Docker\config\daemon.json, where you should add the following lines:

{
    "hosts": ["tcp://0.0.0.0:2375"]
}

Please see more info and configuration options at:

Alternatively you can also execute the dockerd CLI options to set the same:

dockerd -H tcp://0.0.0.0:2375

See more options at the help page:

muratiakos
  • 1,064
  • 11
  • 18
  • Actually i installed docker in windows using the Chocolatey package manager (with the command "choco install -y docker-desktop" ). May be that's why i cannot find a folder C:\ProgramData\Docker\ . – AnjK Mar 19 '19 at 10:41
  • Ah, on newer Windows I rather use the official built-in `Install-Package` powershell command via `PackageManagement` module than the old choco binaries - https://learn.microsoft.com/en-us/powershell/module/packagemanagement/install-package?view=powershell-6 – muratiakos Mar 19 '19 at 11:20
  • Just follow the official Microsoft install notes from here to install docker properly: https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server – muratiakos Mar 19 '19 at 11:21
1

To expose docker daemon over LAN, you should add the following line to the daemon.json file:

{
    "hosts": ["tcp://0.0.0.0:2375"]
}

In windows the daemon.json file location is: %userprofile%\.docker\daemon.json

You can also edit this file from settings, Docker Engine:

enter image description here

More options are described in:

https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file

source: https://stackoverflow.com/a/55352883/1988231

saeedghadiri
  • 196
  • 1
  • 5