-
Notifications
You must be signed in to change notification settings - Fork 2
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
question: how to get Windows hostname from the docker container? #15
Comments
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.
|
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?
The text was updated successfully, but these errors were encountered: