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

Interoperability with Ubuntu bash for windows #371

Open
wclr opened this issue Jan 6, 2017 · 16 comments
Open

Interoperability with Ubuntu bash for windows #371

wclr opened this issue Jan 6, 2017 · 16 comments

Comments

@wclr
Copy link

wclr commented Jan 6, 2017

It is possible to install docker/docker-compose in lightweight Ubuntu for windows and interact with docker for windows docker host, so it works quite ok.

The problem is that ubuntu for windows mounts drives into /mnt (/mnt/c, /mnt/d) and in MobyLinuxVM drives a mount into / (/c, /d), to make it possible to attach/map volumes in ubuntu bash shell current workaround is to make symlinks ln -s /d /mnt/d, after this it works fine.

So for interability with Ubuntu bash for windows I believe it would be reasonable to mount drives in MobyLinuxVM into /mnt (instead of /) by default.

@friism friism changed the title Interability with Ubuntu bash for windows Interoperability with Ubuntu bash for windows Jan 7, 2017
@PetaPetaPeta
Copy link

@whitecolor I can't seem to make the ln -s /d /mnt/d to work correctly. I still get the error: ERROR: build path /mnt/c/... either does not exist, is not accessible, or is not a valid URL. Do you do anything else to make it work?

@wclr
Copy link
Author

wclr commented Jan 30, 2017

@PetaPetaPeta does the link you created indied MobyLinuxVM works ok? First you should mkdir -p /mnt

Btw there is a problem with this workaround that every time docker engine restarts (for example on system reboot) it restores original MobyLinuxVIM image,, so you have to execute commands for liks again (I execute some cli file after each docker start manually which is kind of clumsy but works for me). I think there is another option I didn't try yet that, try to make links in Ubuntu for bash /mnt/d --> /d and see how it works.

@wclr
Copy link
Author

wclr commented Mar 21, 2017

Have you considered this yet?

@aseering
Copy link

aseering commented Apr 5, 2017

Just for clarity: This ticket is specifically referring to Microsoft's "Bash on Windows" / "Windows Subsystem for Linux" feature.

Using this feature, it's possible (indeed, easy -- simply open up a Windows Command Prompt, type bash, and type sudo apt install docker.io) to install and run the Ubuntu Linux Docker command-line binary natively on a Linux machine. Because the Linux binary is running natively, therefore sharing the Windows TCP stack, it's very easy to point the Linux Docker binary at the Docker for Windows server.

However, if you do so, as discussed above, docker -v is broken because Windows paths are mapped differently in the Docker for Windows VM and the Windows Subsystem for Linux.

@wclr
Copy link
Author

wclr commented Apr 5, 2017

The appropriate workaround would be to insert in your .bashrc:

docker run --rm -i --privileged --network=none --pid=host justincormack/nsenter1 /bin/sh -c "mkdir -p /mnt;drives="c d e f g"; for l in $drives; do if [[ -d $l ]] && [[ ! -d /mnt/$l ]]; then  ln -s /$l mnt/$l; fi; done"

This will do the proper mapping inside Moby Linux VM

@copitz
Copy link

copitz commented Jul 28, 2017

@whitecolor This didn't work for me :(

Instead I have the following in my .bashrc:

# mount /mnt/c to /c if not already done
if [ ! -d "/c" ] || [ ! "$(ls -A /c)" ]; then
  echo "Requiring root password to $(tput setaf 6)mount --bind /mnt/c /c$(tput sgr 0)"
  sudo mkdir -p /c
  sudo mount --bind /mnt/c /c
fi

# Change from /mnt/c/... to /c/...
if [ "$(pwd | cut -c -7)" == "/mnt/c/" ]; then
  cd "$(pwd | cut -c 5-)"
fi

# Provide docker for bash and docker-compose
docker() {
  docker.exe "$@"
}

I tried docker-ce installed in bash with the mount solution which works in general but not for symlinks created from within the mounts. Thus I removed docker-ce and added an alias for docker instead.

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

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

@joshrickert
Copy link

This feature would still be very useful. It's the main reason I haven't been able to move my workflow over to WSL.
/remove-lifecycle stale

@edmorley
Copy link

The docker-for-desktop-robot has removed the lifecycle/stale label, however the issue is still closed.
Could someone reopen it please? :-)

@rn
Copy link
Contributor

rn commented May 24, 2018

the robot closed it because the label was not removed within 30 days (it was only removed after). the robot does not look at closed issues...

@rn rn reopened this May 24, 2018
@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

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

@edmorley
Copy link

/lifecycle frozen

@edmorley
Copy link

/remove-lifecycle stale

@ohartl
Copy link

ohartl commented Dec 8, 2018

FYI: You can just change the root to / instead of /mnt in the /etc/wsl.conf, close & open terminal and it should be "automounted" in the correct path

[automount]
root = /

https://blogs.msdn.microsoft.com/commandline/2018/02/07/automatically-configuring-wsl/

@dwheeler
Copy link

dwheeler commented Jan 29, 2019

FYI: You can just change the root to / instead of /mnt in the /etc/wsl.conf

This causes a number of other wsl compatibility issues where other programs have made the assumption that wsl has mounted c to /mnt/c. It's not really a long term solution, just flips around where things break.

@sgtoj
Copy link

sgtoj commented Apr 1, 2019

@dwheeler Suggestion... Try configuring wsl.conf with root = / and mountFsTab = true. Update the fstab file to link the new location to the old location (i.e. by adding /c /mnt/c none bind to the file).

If you do not want to use the wsl.conf, you can use my old method that shared on gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests