我有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:
确切地说,我执行了以下命令:
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 azureuser@104.42.255.141
我用:
export DOCKER_HOST =:2375
然后我开始了我的docker-compose文件:
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
但是我无法通过上述示例中的代理连接到我的网站,我试图去
104.42.144.82:8000
和104.42.144.82:8001/#!/registration
甚至10.0.0.5:8000
我抽出时间.当我在本地运行这个dockerfile时,我会像这样连接到我的网站:
本地主机:8000
和localhost:8001 /#!/ registration
试穿
az --version
azure-cli (2.0.32)
我尝试在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:
- "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上的第一个站点,但我无法访问端口8001上的站点.
如果我将端口从8001更改为80,并保留8000 – 那么我可以在端口80上访问该站点,但在端口8000上的站点上没有.
最佳答案
首先,检查您的docker镜像是否在azure中工作,并且您可以从swarm主服务器打开网页.
原文链接:https://www.f2er.com/docker/436046.htmlssh -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的新规则,稍等片刻.