0
我通過運行運行搬運工,撰寫後,在Amazon EC2上的端口都沒有得到映射到
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $AWS_VPC_ID --amazonec2-region "us-west-2" --engine-opt dns=8.8.8.8 aws-mh-keystore
eval "$(docker-machine env aws-mh-keystore)"
docker run -d -p "8500:8500" -h "consul" progrium/consul -server -bootstrap
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $AWS_VPC_ID --amazonec2-region "us-west-2" --engine-opt dns=8.8.8.8 --engine-label n_type=master --swarm --swarm-master --swarm-strategy "spread" --swarm-discovery="consul://$(docker-machine ip aws-mh-keystore):8500" --engine-opt="cluster-store=consul://$(docker-machine ip aws-mh-keystore):8500" --engine-opt="cluster-advertise=eth0:2376" aws-swarm-master
eval $(docker-machine env --swarm aws-swarm-master)
創建了AWS一個羣的公網IP地址,我使用下面的命令
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $AWS_VPC_ID --amazonec2-region "us-west-2" --engine-opt dns=8.8.8.8 --engine-label n_type=worker --swarm --swarm-discovery="consul://$(docker-machine ip aws-mh-keystore):8500" --engine-opt="cluster-store=consul://$(docker-machine ip aws-mh-keystore):8500" --engine-opt="cluster-advertise=eth0:2376" aws-swarm-node-01
docker-machine create --driver amazonec2 --amazonec2-access-key $AWS_ACCESS_KEY_ID --amazonec2-secret-key $AWS_SECRET_ACCESS_KEY --amazonec2-vpc-id $AWS_VPC_ID --amazonec2-region "us-west-2" --engine-opt dns=8.8.8.8 --engine-label n_type=worker --swarm --swarm-discovery="consul://$(docker-machine ip aws-mh-keystore):8500" --engine-opt="cluster-store=consul://$(docker-machine ip aws-mh-keystore):8500" --engine-opt="cluster-advertise=eth0:2376" aws-swarm-node-02
創建兩個節點
之後,我用下面的命令用來建立自己的多容器應用:
docker-compose up --build
在t他的舞臺,構建過程成功完成,一切都很好。
然而,當我運行
docker-compose ps
我看到暴露的端口是0.0.0.0:<> - > TCP:<> 理想的行爲應該包括從容器到EC2端口映射主辦。
我的搬運工,撰寫文件如下
version: "2"
services:
web_api:
build:
context: .
dockerfile: Dockerfile
# args: ["constraint:engine.labels.n_type==master"]
hostname: web_api
ports:
- "5000:5000"
volumes:
- .:/code
links:
- worker
depends_on:
- worker
# Redis
redis:
build:
context: .
dockerfile: Dockerfile-redis
# image: redis
hostname: redis
ports:
- "6379:6379"
# Celery worker
worker:
build:
context: .
dockerfile: Dockerfile-celery
# args: ["constraint:engine.labels.n_type==worker"]
volumes:
- .:/app
links:
- redis
depends_on:
- redis
# environment:
# - "constraint:engine.labels.n_type == worker"
command: ./run_celery.sh
爲什麼AWS端口映射沒有被分配? 我已經爲正在使用的安全組建立了正確的入站規則。
您是否可以發佈docker-compose ps的輸出? – talentedmrjones
也發佈sudo netstat -ntlp的輸出 – talentedmrjones