Get the host name of the host PC with Docker on Linux

When using the bridge network, on Windows and Mac, host.docker.internal can be resolved from inside the container, and it seems that it can be connected to the host PC.

However, for some reason Linux does not have that feature as of 20200310. There is a sign that it will be possible soon, but ...

Until then, this method seems to be enough to pass the host IP when launching the container.

docker run -it --add-host=host.docker.internal:$(ip route | grep docker0 | awk '{print $9}') debian bash

Recommended Posts

Get the host name of the host PC with Docker on Linux
Specify the project name of docker-compose with Docker integration of Pycharm
Completion of docker command on Linux
Get the host name in Python
[Python] Get the variable name with str
Get the width of the div on the server side with Selenium + PhantomJS + Python
Note: Prepare the environment of CmdStanPy with docker
Prepare the execution environment of Python3 with Docker
Rewrite the name of the namespaced tag with lxml
Get the latest Linux kernel version with Arch Linux
Get the variable name of the variable as a character string.
The story of replacing Nvidia GTX 1650 with Linux Mint 20.1.
Get the sum of each of multiple columns with awk
[C language] [Linux] Get the value of environment variable
Set up Docker on Oracle Linux (7.x) with Vagrant
Try to get the contents of Word with Golang
Preparing the execution environment of PyTorch with Docker November 2019
Easy build of C ++ code with CMake on Docker
Get the operation status of JR West with Python
Announcing the availability of Java 11 LTS on Amazon Linux 2
[Linux] [C / C ++] How to get the return address value of a function and the function name of the caller
Put the latest version of Python on linux (Debian) on Chromebook
Memo to get the value on the html-javascript side with jupyter
Get the id of a GPU with low memory usage
Get UNIXTIME at the beginning of today with a command
Let's execute the command on time with the bot of discord
Check the memory status of the server with the Linux free command
Install the JDK on Linux
Get the number of digits
Access the host SQL Server with python27 / pyodbc on the container
Check the operating status of the server with the Linux top command
Using Docker (Hyper-V) with PyCharm on Windows 10 (as of August 2017)
Until the start of the django tutorial with pycharm on Windows
Paste the link on linux
Install the latest version of Git on your Linux server
To get the name of the primitive etc. generated immediately before
Get the source of the page to load infinitely with python.
You there who want to launch Rails on both the host and the client with Docker Compose!
Read the coordinates of the plot on the graph with Python-matplotlib (super beginner)
I want to get the name of the function / method being executed
How is the progress? Let's get on with the boom ?? in Python
Get the number of PVs of Qiita articles you posted with API
Suspend Thread on Linux (corrected version at the bottom of the article)
Get started with the Python framework Django on Mac OS X
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
On Linux, the time stamp of a file is a little past.
[Django] Correct the plural form of the model name on the management screen
How to get all traffic through VPN with OpenVPN on Linux
Check the memory protection of linux kerne with the code for ARM
Create a Docker container image with JRE8 / JDK8 on Amazon Linux
I checked the image of Science University on Twitter with Word2Vec.
Host the network library Mirror for Unity on a Linux server
PhytoMine-I tried to get the genetic information of plants with Python
The day of docker run (note)
Get started with MicroPython (on macOS)
Get the weather with Python requests
Get the attributes of an object
Get the first element of queryset
[Linux] Docker environment construction on Redhat
Get the number of Youtube subscribers
I tested whether the Windows disk performance of the KVM guest changes depending on the Linux file system of the host.