🖥

Docker for mac で OSに設定した SOCKS proxy を利用して ssh サーバー経由で外部アクセスする ( #dock

2019/11/07に公開

Mac = host で SOCKS proxy を起動させておく

ssh -vND 8888 user@host

docker コンテナで proxy 接続を確認

host.docker.internal を利用

proxy利用時と非利用時でIPが変わっていたら成功

$ docker run -it alpine ash
/ # apk add curl
/ # curl  https://httpbin.org/ip
/ # https_proxy=socks5://host.docker.internal:8888 curl  https://httpbin.org/ip

参考

#docker で SOCKS proxy を利用して ssh サーバー経由の https 接続をする - Qiita

Networking features in Docker Desktop for Mac | Docker Documentation

I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST
The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.

The gateway is also reachable as gateway.docker.internal.

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2675

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-11-07

Discussion