我正在尝试将一堆服务部署到docker for mac。让我先说一下,将我的堆栈部署到一个真正的群体中是完美的。
我为mac Beta版本17.05.0-ce-rc1-mac8(16582)运行docker。我确实在其上运行了swarm init
。
这是我的yaml档案:
version: "3"
services:
proxy:
image: traefik:1.2-alpine
command: --web --docker --docker.swarmmode --docker.domain=docker.localhost --docker.watch --debug --logLevel=DEBUG \
--entryPoints='Name:https Address::443 TLS' \
--entryPoints='Name:http Address::80 Redirect.EntryPoint:https' \
--acme=true \
--acme.entryPoint=https \
--acme.email=myemail@gmail.com \
--acme.storage=/etc/traefik/acme/acme.json \
--acme.domains=mydomain.com \
--acme.ondemand=true \
--acme.onhostrule=true
networks:
- proxy
ports:
- 80:80
- 443:443
- 8080:8080
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- traefikdata:/etc/traefik/acme
deploy:
placement:
constraints:
- node.labels.env == prod
- node.role == manager
- node.labels.traefik == yes
volumes:
traefikdata:
driver: local-persist
driver_opts:
mountpoint: ${MOUNTPOINT}/data/traefik
networks:
proxy:
driver: overlay
问题是,docker stack services proxy
返回REPLICAS 0/1。显然它正在等待什么。 docker service logs proxy_proxy
根本不返回任何内容。这是syslog -k Sender Docker
的输出:
Apr 24 22:15:21 MacBook-Pro Docker[2567] <Warning>: DNS lookup registry-1.docker.io AAAA: NoSuchRecord
Apr 24 22:15:21 MacBook-Pro Docker[2567] <Notice>: DNS lookup registry-1.docker.io A: registry-1.docker.io <IN|19> [A (34.205.194.204)], registry-1.docker.io <IN|19> [A (34.239.237.19)], registry-1.docker.io <IN|19> [A (107.23.152.57)], registry-1.docker.io <IN|19> [A (50.17.48.108)], registry-1.docker.io <IN|19> [A (52.0.56.248)], registry-1.docker.io <IN|19> [A (52.45.235.210)]
Apr 24 22:15:21 MacBook-Pro Docker[2567] <Warning>: DNS lookup auth.docker.io AAAA: NoSuchRecord
Apr 24 22:15:21 MacBook-Pro Docker[2567] <Notice>: DNS lookup auth.docker.io A: auth.docker.io <IN|38> [A (34.205.194.204)], auth.docker.io <IN|38> [A (52.45.235.210)], auth.docker.io <IN|38> [A (52.0.56.248)], auth.docker.io <IN|38> [A (34.239.237.19)], auth.docker.io <IN|38> [A (50.17.48.108)], auth.docker.io <IN|38> [A (107.23.152.57)]
Apr 24 22:15:22 MacBook-Pro Docker[2567] <Notice>: DNS lookup registry-1.docker.io A: registry-1.docker.io <IN|19> [A (34.205.194.204)], registry-1.docker.io <IN|19> [A (34.239.237.19)], registry-1.docker.io <IN|19> [A (107.23.152.57)], registry-1.docker.io <IN|19> [A (50.17.48.108)], registry-1.docker.io <IN|19> [A (52.0.56.248)], registry-1.docker.io <IN|19> [A (52.45.235.210)]
Apr 24 22:15:22 MacBook-Pro Docker[2567] <Warning>: DNS lookup registry-1.docker.io AAAA: NoSuchRecord
我不知道这是否正常,图片是否已正确下载。
现在,我该如何解决正在发生的事情?顺便说一下:我确实应用了所有必要的标签,这里是docker inspect moby
的输出:
[
{
"ID": "13xgtap3b898mwrxryj21phr5",
"Version": {
"Index": 41
},
"CreatedAt": "2017-04-24T19:41:30.814976621Z",
"UpdatedAt": "2017-04-24T20:21:21.157096648Z",
"Spec": {
"Labels": {
"env": "prod",
"traefik": "yes"
},
"Role": "manager",
"Availability": "active"
},
"Description": {
"Hostname": "moby",
"Platform": {
"Architecture": "x86_64",
"OS": "linux"
},
"Resources": {
"NanoCPUs": 4000000000,
"MemoryBytes": 2095894528
},
"Engine": {
"EngineVersion": "17.05.0-ce-rc1",
"Plugins": [
{
"Type": "Network",
"Name": "bridge"
},
{
"Type": "Network",
"Name": "host"
},
{
"Type": "Network",
"Name": "ipvlan"
},
{
"Type": "Network",
"Name": "macvlan"
},
{
"Type": "Network",
"Name": "null"
},
{
"Type": "Network",
"Name": "overlay"
},
{
"Type": "Volume",
"Name": "local"
},
{
"Type": "Volume",
"Name": "local-persist"
}
]
}
},
"Status": {
"State": "ready",
"Addr": "192.168.65.2"
},
"ManagerStatus": {
"Leader": true,
"Reachability": "reachable",
"Addr": "192.168.65.2:2377"
}
}
]
另外,我在另一个容器中使用local-persist驱动程序。
答案 0 :(得分:0)
查找proxy
服务的任务状态。它会告诉你为什么服务底层的任务失败,这可以解释为什么你的服务永远不会超过0/1复制品。
您可以使用docker service ps $SERVICE_NAME
找到特定服务的任务。或者,使用docker stack ps $STACK_NAME
的堆栈服务的所有任务。
在任何一种情况下,从第一列中挑选任务ID,然后使用docker inspect $TASK_ID
获取任务详细信息。对于Status
,running
部分可能会说State
以外的内容,而Message
则会出错。