我正在尝试在 AWS ECS(弹性容器服务)上运行的基于 docker 的应用程序上获取 HTTPS 证书。但是,当最终尝试将 docker 实例部署到 ECS 时,我遇到了一个未定义的问题。
INFO[0120] (service deploy) has started 1 tasks: (task f..........6). timestamp=2018-03-21 14:52:17 +0000 UTC
FATA[0301] Deployment has not completed: Running count has not changed for 5.00 minutes
我的设置基于https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion,他利用了https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion
不幸的是,两者都没有给出 AWS ECS 的明确示例。我添加的是环境变量 DOCKER_PROVIDER=ecs 在 let's encrypt 容器的环境变量中。在创建我的 docker 容器并将它们上传到 ECS 后,我运行了一个特定于 ecs 的 docker-compose
ecs-cli compose --file docker-compose_ec.yml service up
看起来像
version: '2'
services:
nginx-web:
image: 12344.dkr.ecr.eu-central-1.amazonaws.com/abc_nginx
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy:
"true"
container_name: ${NGINX_WEB}
restart: always
ports:
- "$0.0.0.0:80:80"
- "$0.0.0.0:443:443"
volumes:
- ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
- ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
- ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
- ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
- ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro
logging:
options:
max-size: 4m
max-file: 10
nginx-gen:
image: 12344.dkr.ecr.eu-central-1.amazonaws.com/abc_gen
command: -notify-sighup ${NGINX_WEB} -watch -wait 5s:30s
/etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
container_name: abc_gen
restart: always
volumes:
- ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
- ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
- ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
- ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
- ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
logging:
options:
max-size: 2m
max-file: 10
nginx-letsencrypt:
image: 12344.dkr.ecr.eu-central-1.amazonaws.com/abc_le
container_name: abc_le
restart: always
volumes:
- ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
- ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
- ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
- ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
NGINX_DOCKER_GEN_CONTAINER: abc_gen
NGINX_PROXY_CONTAINER: abc_nginx
DOCKER_PROVIDER: ecs
logging:
options:
max-size: 2m
max-file: 10
api:
image: 12344.dkr.ecr.eu-central-1.amazonaws.com/abc_api
cpu_shares: 50
mem_limit: 262144000
ports:
- '5005:5005'
web:
image: 12344.dkr.ecr.eu-central-1.amazonaws.com/abc_web
cpu_shares: 100
mem_limit: 262144000
links:
- api
environment:
- API_URL=http://api:5005
- VIRTUAL_HOST=example.com
- VIRTUAL_PORT=5000
- LETSENCRYPT_HOST=example.com
- LETSENCRYPT_EMAIL=mike@example.com
networks:
default:
external:
name: ${NETWORK}
Web 应用程序在端口 5000 上运行。使用 let's encrypt 运行 Web 应用程序和 api 没有问题。
任何想法如何使它与 AWS ECS 一起工作?