Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing docker from bash under windows subsystem for linux #1480

Closed
sohailalam2 opened this issue Jan 3, 2018 · 11 comments
Closed

Accessing docker from bash under windows subsystem for linux #1480

sohailalam2 opened this issue Jan 3, 2018 · 11 comments

Comments

@sohailalam2
Copy link

Expected behavior

Windows subsystem for linux allows us to run bash shell.
Docker should be accessible from this shell also (as we are able to do it from windows command prompt).

Actual behavior

command not found: docker

Information

  • Windows 10 Pro version 1709, OS Build 16299.125
  • Docker version 17.09.1-ce, build 19e2cf6

Steps to reproduce the behavior

  1. Install docker for windows
  2. Enable "Windows subsystem for linux"
  3. Install Ubuntu bash or zsh terminal
  4. Run docker -v in ubuntu bash shell
@jasonbivins
Copy link

Hi @sohailalam2
This is a bit of a roundabout way to access Docker, but i've been able to use it in the past by adding .exe to my docker commands. docker.exe run hello-world I was also unable to get any containers to display interactive prompts.
There is a great utility here that might help simplify the connection though:
https://github.com/jstarks/npiperelay

@tallaxes
Copy link

tallaxes commented Jan 5, 2018

You will need to check "Expose daemon on tcp://localhost:2375" in Docker for Windows configuration, and get Docker client (only the client is needed):

curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-17.09.1-ce.tgz | sudo tar -C /usr/local/bin -xz --strip=1 docker/docker
export DOCKER_HOST=tcp://localhost:2375
docker version

Alternatively (from Windows 10 Anniversary Update build 14951 and later) you could just point WSL to the Windows client (no need to "Expose daemon …", Windows client uses named pipe)

@sohailalam2
Copy link
Author

Thanks @jasonbivins this did the trick for me too :) docker.exe --version

@geerlingguy
Copy link

Note that I tried using docker-compose.exe up -d to bring up a Compose environment under Ubuntu in WSL, but it said 'Can't find a suitable configuration file in this directory', I'm guessing because the environment in which the Windows executable runs doesn't have the path to where the WSL/Ubuntu current directory is :(

Is there any way one could use a Docker Compose file to bring up an environment within Ubuntu/WSL, or do I have to switch back over to PowerShell so Docker Compose can pick up the compose file?

@geerlingguy
Copy link

Something with my Docker install must've been messed up; I went into settings and reset Docker to factory defaults, and now it seems to be working whether using docker-compose.exe in WSL or docker-compose in PowerShell.

@cldambrosio
Copy link

This solved it for me:

accessing-docker-from-bash-on-ubuntu-on-windows

@ripper234
Copy link

Tried the above, docker-compose still complains that it can't find the config file.

@CajuCLC
Copy link

CajuCLC commented Apr 26, 2018

I also tried the above and at first it didn't work. I restarted Windows and Docker and now it's working fine.
It didn't work using docker-composer.exe up -d, it only worked when running as docker-compose up -d

@rn
Copy link
Contributor

rn commented Apr 28, 2018

Looks like this issues is resolved so I'm closing it.

In general, we don't support running the docker CLI in WSL against Docker for Windows as WSL is still under heavy development. It may work with recent versions (as some of you reported) but we don't test this configuration.

@rn rn closed this as completed Apr 28, 2018
@alexandis
Copy link

This solved it for me:

accessing-docker-from-bash-on-ubuntu-on-windows

And how to "reload the environment"?

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Jun 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants