首页 > 解决方案 > Docker 服务运行但未绑定到主机端口给出 503 Service Unavailable

问题描述

Docker 服务应该绑定到 2007 端口。

root@docker:~# docker service ls | grep 2007
hn7ljux4l6ib   access_agency_overview-feature        replicated   1/1        docker-repo.com/access_agency_overview:feature       *:2007->80/tcp

还要检查docker inspect端口是否已发布。看起来很棒

root@docker:~# docker service inspect hn7ljux4l6ib | grep Port
                "Ports": [
                        "TargetPort": 80,
                        "PublishedPort": 2007,
                "Ports": [
                        "TargetPort": 80,
                        "PublishedPort": 2007,
            "Ports": [
                    "TargetPort": 80,
                    "PublishedPort": 2007,

看起来也很棒docker logs

root@docker:~# docker logs 047166727d33
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up

netstat -tulnp | grep 2007没有输出。

以及卷曲到本地主机

root@docker:~# curl http://localhost:2007
curl: (7) Failed to connect to localhost port 2007: Connection refused

附言。2007 允许在防火墙上

编辑添加结果来自docker ps

047166727d33   docker-repo.com/access_agency_overview:feature       "/docker-entrypoint.…"   24 minutes ago      Up 24 minutes      80/tcp                   access_agency_overview-feature.1.ucti38zri157sc8014y0f3cjq

标签: docker

解决方案


推荐阅读