Open d-sphinx opened 6 months ago
C:\>echo %COMPUTERNAME%
foobar
C:\>docker run -e WINDOWS_COMPUTER_NAME=%COMPUTERNAME% -it ubuntu bash
root@b4143f2b77fc:/# echo $WINDOWS_COMPUTER_NAME
foobar
you can also set the hostname (for a specific docker container) via -h
C:\>docker run -h foobar.whatever -it ubuntu bash
root@foobar:/# hostname
foobar.whatever
Voila for the boot2docker.
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.103
For help getting started, check out the docs at https://docs.docker.com
Start interactive shell
foo@XXX MINGW64 /c/Program Files/Toolbox2docker
$ docker-machine ssh
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
docker@default:~$ sudo su -
root@default:~# echo host.docker.internal > /var/lib/boot2docker/etc/hostname
root@default:~# reboot
foo@XXX MINGW64 /c/Program Files/Toolbox2docker
$ docker-machine ssh
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
docker@host:~$ hostname
host.docker.internal
Thanks @egandro for that. There is also good information at https://nickjanetakis.com/blog/connect-to-a-service-running-on-your-docker-host-from-a-container
172.17.0.1 is not working for me. I still can't access the Xdebug IDE. But 192.168.100.5 is working. Just type "ipconfig" and see what addresses are there. Cheers!
If you are after information about the boot2docker host the docker-machine command is what your after. NOTE: the IP address range and subnet information will be different depending on the Virtualisation application ie virtual box, VMware, VMware fusion, etc and it's networking setup.
Starting "default"...
(default) Starting default...
(default) Waiting for VM to come online...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the 'docker-machine env' command.
kristamari-w1:~/development/bin>docker-machine ip default
192.168.251.128
kristamari-w1:~/development/bin>docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - vmware Running tcp://192.168.251.128:2376 v26.1.3
kristamari-w1:~/development/bin>docker-machine env
setenv DOCKER_TLS_VERIFY "1";
setenv DOCKER_HOST "tcp://192.168.251.128:2376";
setenv DOCKER_CERT_PATH "/Users/XXX/.docker/machine/machines/default";
setenv DOCKER_MACHINE_NAME "default";
: Run this command to configure your shell:
: eval 'docker-machine env'
Sorry, but I couldn't find how to ask other way. Usually in Docker for Windows it is host.docker.internal, but how does this work in Toolbox? Is that possible?