泊坞窗:不能访问容器主机/端口
问题描述:
我有一个容器泊坞窗:不能访问容器主机/端口
ps -a
de3ff650fbef tasklist-img "/bin/sh -c 'java -ja" 2 minutes ago Up 2 minutes 8080/tcp, 0.0.0.0:8080->8081/tcp tasklist-img-01
,不能像本地主机访问:8080 /任务列表
当我检查我有IP地址为172.17 JSON。 0.2,也可达
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "82398f58a56f6685223df13f0e053c1ad388505ff595ec270eb4e9a445109641",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": null,
"8081/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/82398f58a56f",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "e8d9d3e209e858d6e881295899949df457fd8ca28cb059105bebceb6015e1e7d",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "24ef0b8e2aea470b5a0c4e48b96e5b203ea35b291689fe6d73b71b870c86f659",
"EndpointID": "e8d9d3e209e858d6e881295899949df457fd8ca28cb059105bebceb6015e1e7d",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
我的搬运工机器在IP 192.168.99.100 跑我跑容器命令
docker run -d -p 8080:8081 --name tasklist-img-01 tasklist-img
我可以访问http://192.168.99.100:8080/,它是只返回dropwizard指标,http://192.168.99.100:8080/task-list/可达
我也登录
INFO [2016-11-14 19:32:29,324] io.dropwizard.server.DefaultServerFactory: Registering admin handler with root path prefix:/
INFO [2016-11-14 19:32:29,402] org.eclipse.jetty.setuid.SetUIDListener: Opened [email protected]{HTTP/1.1}{0.0.0.0:8080}
INFO [2016-11-14 19:32:29,402] org.eclipse.jetty.setuid.SetUIDListener: Opened [email protected]{HTTP/1.1}{0.0.0.0:8081}
INFO [2016-11-14 19:32:29,406] org.eclipse.jetty.server.Server: jetty-9.2.z-SNAPSHOT
INFO [2016-11-14 19:32:30,428] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET /task-list (com.bjedrzejewski.tasklistservice.TaskListResource)
GET /task-list/big (com.bjedrzejewski.tasklistservice.TaskListResource)
INFO [2016-11-14 19:32:30,435] org.eclipse.jetty.server.handler.ContextHandler: Started [email protected]{/,null,AVAILABLE}
INFO [2016-11-14 19:32:30,450] io.dropwizard.setup.AdminEnvironment: tasks =
POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)
WARN [2016-11-14 19:32:30,451] io.dropwizard.setup.AdminEnvironment:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! THIS APPLICATION HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW !
! IF IT DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE !
! LETTING YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH OF YOUR !
! APPLICATION'S DEPENDENCIES WHICH FULLY (BUT LIGHTLY) TESTS IT. !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
INFO [2016-11-14 19:32:30,456] org.eclipse.jetty.server.handler.ContextHandler: Started [email protected]{/,null,AVAILABLE}
INFO [2016-11-14 19:32:30,486] org.eclipse.jetty.server.ServerConnector: Started [email protected]{HTTP/1.1}{0.0.0.0:8080}
INFO [2016-11-14 19:32:30,487] org.eclipse.jetty.server.ServerConnector: Started [email protected]{HTTP/1.1}{0.0.0.0:8081}
,所以我不能明白的地方是我的微服务?:)))
答
看起来像你映射的端口8081
的容器到8080
的主机
docker run -d -p 8080:8081
而且有端口监听8080
和8081
INFO [2016-11-14 19:32:30,486] org.eclipse.jetty.server.ServerConnector: Started [email protected]{HTTP/1.1}{0.0.0.0:8080}
INFO [2016-11-14 19:32:30,487] org.eclipse.jetty.server.ServerConnector: Started [email protected]{HTTP/1.1}{0.0.0.0:8081}
您可以访问它,当然,不过这并不是容器的真正8080
。 你可能需要发布端口范围
docker run -d -p 8080-8081:8080-8081
+0
谢谢,这是错误的,现在它的工作原理就像http://192.168.99.100:8080/task-list –
的为什么'boot2docker'标签?你是不是在操作系统上使用各自的本地Docker? –
不,我安装了DockerToolbox-1.12.2.exe,是不是更好?:( –
我想如果你不在Windows 10上,那么从来没有想过 –