0
0

More than 1 year has passed since last update.

Dockerコンテナからホストにアクセスする(ホストのIPアドレス取得方法)for Linux

Posted at

方法

docker run--add-host=host.docker.internal:host-gateway オプションを付ける。

docker run -it --add-host=host.docker.internal:host-gateway python bash

コンテナ内にて、cat /etc/hostshost.docker.internal が追加されていることが分かる。

cat /etc/hosts

127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.65.2    host.docker.internal
172.17.0.3      c755951ee0f1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0