我正在使用Docker 18.05和Docker Swarm来部署具有滚动更新的多个任务的服务。有时,3个任务中有1个没有使用最新版本进行更新。 阅读完这个问题后,我在docker compose文件中添加了标记,以确保它能够提取最新的图像。我也转移到Amazon ECR而不是本地注册表,但它没有解决问题。
这是一个抽象的问题,但我不知道如何解决它。 此外,是否有任何部署日志可以帮助我了解已收到更新的任务?
部署代码:
sudo docker-compose build
sudo docker-compose push
sudo docker stack deploy --compose-file docker-compose.yml --prune --resolve-image always --with-registry-auth my_stack
撰写配置(相关部分):
web:
restart: always
deploy:
replicas: 3
update_config:
delay: 10s
restart_policy:
condition: any
placement:
constraints:
- node.role == manager
服务检查:
[
{
"ID": "sj0mx9wzwec3totulzx1nrzrw",
"Version": {
"Index": 510
},
"CreatedAt": "2018-06-01T21:49:43.34465496Z",
"UpdatedAt": "2018-06-02T00:19:14.379304654Z",
"Spec": {
"Name": "my_stack_webserver",
"Labels": {
"com.docker.stack.image": "xxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19",
"com.docker.stack.namespace": "my_stack"
},
"TaskTemplate": {
"ContainerSpec": {
"Image": "xxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19@sha256:f7e1f4746703c537449b6c1c7c6ee5c55ada3b8e564de5575a83a76c3188f8a6",
"Labels": {
"com.docker.stack.namespace": "my_stack"
},
"Args": [
"bash",
"-c",
"python /code/manage.py collectstatic --noinput \u0026\u0026 python /code/manage.py migrate --noinput \u0026\u0026 gunicorn -c /code/gunicorn_conf.py app_reader.wsgi:application"
],
"Env": [
],
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Mounts": [
{
"Type": "volume",
"Source": "my_stack_log-data",
"Target": "/home/log_data",
"VolumeOptions": {
"Labels": {
"com.docker.stack.namespace": "my_stack"
},
"DriverConfig": {
"Name": "local"
}
}
}
],
"StopGracePeriod": 10000000000,
"DNSConfig": {},
"Isolation": "default"
},
"Resources": {},
"RestartPolicy": {
"Condition": "any",
"Delay": 5000000000,
"MaxAttempts": 0
},
"Placement": {
"Constraints": [
"node.role == manager"
],
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "l28idb1gahjv5jzqtf0xtkauz",
"Aliases": [
"my_web"
]
}
],
"ForceUpdate": 0,
"Runtime": "container"
},
"Mode": {
"Replicated": {
"Replicas": 3
}
},
"UpdateConfig": {
"Parallelism": 1,
"Delay": 10000000000,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"RollbackConfig": {
"Parallelism": 1,
"FailureAction": "pause",
"Monitor": 5000000000,
"MaxFailureRatio": 0,
"Order": "stop-first"
},
"EndpointSpec": {
"Mode": "vip",
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 9000,
"PublishedPort": 9000,
"PublishMode": "ingress"
}
]
}
},
},
"Endpoint": {
"Spec": {
"Mode": "vip",
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 9000,
"PublishedPort": 9000,
"PublishMode": "ingress"
}
]
},
"Ports": [
{
"Protocol": "tcp",
"TargetPort": 9000,
"PublishedPort": 9000,
"PublishMode": "ingress"
}
],
"VirtualIPs": [
{
"NetworkID": "xw3mgpih0btibuoixvhmlm8cl",
"Addr": "10.255.0.4/16"
},
{
"NetworkID": "l28idb1gahjv5jzqtf0xtkauz",
"Addr": "10.0.0.4/24"
}
]
},
"UpdateStatus": {
"State": "updating",
"StartedAt": "2018-06-02T00:19:14.379283065Z",
"Message": "update in progress"
}
}
]
更新:
我删除了重启和重启策略,但没有解决问题。
我也尝试将order: start-first
添加到配置中它确实解决了问题,但由于某种原因,我在第二个容器更新时有1秒的停机时间。
这是泊坞窗事件日志:
2018-06-05T19:00:12.288664241Z service update sj0mx9wzwec3totulzx1nrzrw (image.new=xxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-05-19-00, image.old=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-05-18-49, name=my_stack_web)
2018-06-05T19:00:12.292079302Z service update sj0mx9wzwec3totulzx1nrzrw (name=my_stack_web, updatestate.new=updating)
2018-06-05T19:00:12.510796471Z container create 5763d590cec1ec721e3d006b2ae80c089aa7c6a71ceef94d1b33b74bbc21f0ea (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=3tnyzawizq3m8a7q6oyddjxoj, com.docker.swarm.task.name=my_stack_web.3.3tnyzawizq3m8a7q6oyddjxoj, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-05-19-00@sha256:55025c54a45459d7d2460b4fcbd97498c482db0b0571c36a286b8c343214c145, name=my_stack_web.3.3tnyzawizq3m8a7q6oyddjxoj)
2018-06-05T19:00:13.298951303Z container create 93aeec4d847c0fbcdb2b1bd968b46cb40ccf5e728a481dfd309a9662c1125e1f (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=2bx8d8825ls5dkjg4um9a3k01, com.docker.swarm.task.name=my_stack_web.3.2bx8d8825ls5dkjg4um9a3k01, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-05-19-00@sha256:55025c54a45459d7d2460b4fcbd97498c482db0b0571c36a286b8c343214c145, name=my_stack_web.3.2bx8d8825ls5dkjg4um9a3k01)
2018-06-05T19:00:13.851025262Z container start 93aeec4d847c0fbcdb2b1bd968b46cb40ccf5e728a481dfd309a9662c1125e1f (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=2bx8d8825ls5dkjg4um9a3k01, com.docker.swarm.task.name=my_stack_web.3.2bx8d8825ls5dkjg4um9a3k01, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-05-19-00@sha256:55025c54a45459d7d2460b4fcbd97498c482db0b0571c36a286b8c343214c145, name=my_stack_web.3.2bx8d8825ls5dkjg4um9a3k01)
2018-06-05T19:00:15.256815506Z container destroy 5763d590cec1ec721e3d006b2ae80c089aa7c6a71ceef94d1b33b74bbc21f0ea (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=3tnyzawizq3m8a7q6oyddjxoj, com.docker.swarm.task.name=my_stack_web.3.3tnyzawizq3m8a7q6oyddjxoj, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-05-19-00@sha256:55025c54a45459d7d2460b4fcbd97498c482db0b0571c36a286b8c343214c145, name=my_stack_web.3.3tnyzawizq3m8a7q6oyddjxoj)
2018-06-05T19:00:15.470736086Z container kill 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, signal=15)
2018-06-05T19:00:15.714691366Z container kill 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, signal=15)
2018-06-05T19:00:25.482250914Z container kill 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, signal=9)
2018-06-05T19:00:25.559283083Z container die 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, exitCode=137, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y)
2018-06-05T19:00:25.818572261Z container stop 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y)
2018-06-05T19:00:25.818598479Z container stop 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y)
2018-06-05T19:00:25.846005241Z container destroy 6d2ecb46065cc5d04b3f24a120c60e892d670b0b1cdd0c95812f760777f4df32 (com.docker.stack.namespace=my_stack, com.docker.swarm.node.id=kf9xehdk4zws2ufl3ouu8l4gr, com.docker.swarm.service.id=sj0mx9wzwec3totulzx1nrzrw, com.docker.swarm.service.name=my_stack_web, com.docker.swarm.task=, com.docker.swarm.task.id=xjh1ds0gkf14g6mxw9zz0lp1y, com.docker.swarm.task.name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y, image=xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/webserver:2018-06-02-00-19, name=my_stack_web.3.xjh1ds0gkf14g6mxw9zz0lp1y)