使用CLI通过docker-compose部署到Azure时访问代理页面时超时 [英] Deployment with docker-compose to Azure using CLI gives timeout when visiting agent page

查看:113
本文介绍了使用CLI通过docker-compose部署到Azure时访问代理页面时超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 docker-compose 文件:

version: "3"
services:
  app2:
    image: kamilwit/dockerdocker_app2
    container_name: app2
    build:
      context: ./app2
    volumes:
      - app2data:/data
    environment:
      - LOGGING_LOG-FILES-PATH=/opt/tomcat/logs
    ports:
      - "8000:8080"
  app:
    image: kamilwit/dockerdocker_app
    container_name: app
    build:
      context: ./app
    volumes:
      - app1data:/data
    environment:
      - LOGGING_LOG-FILES-PATH=/opt/tomcat/logs
    ports:
      - "8001:8080"
volumes:
  app1data:
  app2data:

我遵循了 https://docs.microsoft.com/en-us/天蓝色/容器服务/ dcos-swarm / container-service-swarm-walkthrough

确切地说,我执行了以下命令:

To be exact I executed the following commands:

az group create --name myResourceGroup --location westus

az acs create --name mySwarmCluster --orchestrator-type Swarm --resource-group myResourceGroup --generate-ssh-keys --agent-count 1

然后我得到了的输出来自

az network public-ip list --resource-group myResourceGroup --query "[*].{Name:name,IPAddress:ipAddress}" -o table

Name                                                            IPAddress
--------------------------------------------------------------  --------------
swarm-agent-ip-myswarmclu-myresourcegroup-76f1d9agent-EEACED89  104.42.144.82
swarm-master-ip-myswarmclu-myresourcegroup-76f1d9mgmt-EEACED89  104.42.255.141

我通过以下方式连接到ssh:
ssh -p 2200 -fNL 2375:localhost: 2375天青星@ 10 4.42.255.141
i使用:

I connect to ssh with: ssh -p 2200 -fNL 2375:localhost:2375 azureuser@104.42.255.141 i use:

export DOCKER_HOST =:2375

然后我启动了docker-compose文件:
docker-compose up -d

then I started my docker-compose file: docker-compose up -d

docker ps 的输出为:

docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                     NAMES
3bfff4427e44        kamilwit/dockerdocker_app    "/bin/sh /data/app..."   18 minutes ago      Up 8 minutes        10.0.0.5:8001->8080/tcp   swarm-agent-EEACED89000001/app
c297ea34547e        kamilwit/dockerdocker_app2   "/bin/sh /data/app..."   18 minutes ago      Up 8 minutes        10.0.0.5:8000->8080/tcp   swarm-agent-EEACED89000001/app2

但是我无法通过<$连接到我的网站在上例中来自 agent 的c $ c> ip 我尝试转到
104.42.144.82:8000
1 04.42.144.82:8001/#!/注册
甚至 10.0.0.5:8000

However I am unable to connect to my site by ip from agent in the example above I tried going to 104.42.144.82:8000 and 104.42.144.82:8001/#!/registration or even 10.0.0.5:8000

我超时了。当我在本地运行此dockerfile时,我会像这样连接到我的站点:$ b​​ $ b localhost:8000
localhost:8001 / #!/注册

I get a time out. When i run this dockerfile locally, I connect like that to my sites: localhost:8000 and localhost:8001/#!/registration

尝试过

az --version
azure-cli (2.0.32)

我尝试打开 Azure 中的端口:

https://imgur.com/cjslLMN

https://imgur.com/nSAQdLS

但这没有帮助。
我尝试过也通过手机(该网站上的另一个网络)打开该站点没有帮助。

But that did not help. I tried also opening the site from mobile phone (another network on it) did not help.

编辑:

使用 docker-compose

version: "3"
services:
  app2:
    image: kamilwit/dockerdocker_app2
    container_name: app2
    build:
      context: ./app2
    volumes:
      - app2data:/data
    environment:
      - LOGGING_LOG-FILES-PATH=/opt/tomcat/logs
    ports:
      - "80:8080"
  app:
    image: kamilwit/dockerdocker_app
    container_name: app
    build:
      context: ./app
    volumes:
      - app1data:/data
    environment:
      - LOGGING_LOG-FILES-PATH=/opt/tomcat/logs
    ports:
      - "8001:8080"
volumes:
  app1data:
  app2data:

,并按照与我可以在端口80上访问第一个站点的问题,但我无法访问s网站位于端口8001上。
如果我将端口从8001更改为80,并保留8000,那么我可以访问端口80上的站点,但不能访问端口8000上的站点。

and following the same steps from the question I can access first site on port 80, but i can not access site on port 8001. If i changed port from 8001 to 80, and leave 8000 - then i can access to the site on port 80 but no on the site on port 8000.

推荐答案

首先,检查您的docker映像是否可以在Azure中正常工作,然后可以从swarm master服务器打开网页。

First, check if your docker image works in azure, and you can open web page from swarm master server.

ssh -p 2200 azureuser@104.42.255.141 # Connect via ssh to your swarm master
sudo apt-get install lynx # Install lynx - console web browser 
docker ps # check IP address of app
lynx 10.0.0.5:8000 # Open your app in lynx (using private IP address)

如果页面未加载,则图像有问题或您的应用无法正常启动。
如果页面加载,则意味着网络基础结构存在问题。群集代理的负载均衡器中可能缺少规则。默认情况下,在 80 443 8080 。只需为 8000 添加新规则,然后稍等片刻。

If page doesn't load then there is a problem with the image or your app didn't start properly. If page loads, it means there is a problem with network infrastructure. Probably there is missing rules in load balancer for swarm agent. By default, there are open ports at 80, 443 and 8080. Just add new rule for 8000, and wait a moment.

这篇关于使用CLI通过docker-compose部署到Azure时访问代理页面时超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆