Я использую Docker 18.05 с Docker Swarm для развертывания службы с несколькими задачами с непрерывным обновлением.Иногда 1 из 3 задач не обновляется до последней версии.Прочитав эту проблему, я добавил теги к изображению в файле компоновки Docker, чтобы убедиться, что он извлекает последнее изображение.Я также перешел на 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)