![](/img/trans.png)
[英]jupyterhub in docker container not able to connect to external directory
[英]Docker container not able to connect with docker container name as hostname
我有一個 docker 網絡,其中包含我的應用程序。 我無法啟動我的 selenium 應用程序以連接到 web 應用程序,並且必須使用原始 IP 才能工作。 如果我使用 docker 容器名稱作為主機名,則會出現以下錯誤。
收到錯誤:
ERROR: for ad622a7aeb92_traffic_app UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=120)
ERROR: for java UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=120)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 120).
Docker網絡:
[
{
"Name": "dummy_network",
"Id": "06f5a0f36fa58c50faece96f09a358d9696a137fef1c13d465827c69c0325ba7",
"Created": "2021-10-13T06:52:41.016380256Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"034cfe8afbe3bb40651a87742fa9fccbefee3b6ecb0bba9da0d224de8442f495": {
"Name": "dummy_app_1",
"EndpointID": "1bf4fb176bee5979e9dcbd65a1b12dd5ea5a8b7f4fbafeaf27c3146c9e032780",
"MacAddress": "02:42:ac:12:00:06",
"IPv4Address": "172.18.0.6/16",
"IPv6Address": ""
},
"5d2e33ac8bb3aef1e1d7436cfbc247b254ab1d6978c23a44b5f2c831a88be66d": {
"Name": "dummy_mysql",
"EndpointID": "7f0d41a7d8d8cebd9dd4550c072a76b03cf2acf4916fa05aec5a9fb65b671a6c",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
},
"872d20d9a9ae67e95244ab6082621fe16034a9677c265cf0d5f50f3854f6bbf5": {
"Name": "traffic_app",
"EndpointID": "39a58ffb2ac4569f3ccf7b87c545cd3cab7c0dcf3ba61529fc7c1ac54fe3819e",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
這是我的 docker-compose 文件,它連接到dummy_network
但它似乎無法使用 docker 容器名稱作為主機名連接到其他 docker 容器。 docker-compose
文件:
version: "3.7"
networks:
default:
external: true
name: dummy_network
services:
java:
container_name: traffic_app
restart: always
build: .
解決了。 發現我的容器沒有主機名標簽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.