简体   繁体   English

Docker Swarm:如何实现按需滚动更新?

[英]Docker Swarm: how to do a rolling update on demand?

How can one execute a rolling update on a docker swarm service on demand?如何按需对 docker 群服务执行滚动更新?

My scenario: I have a Github Action that will test my code, build the docker containers and pull to Docker Hub.我的场景:我有一个 Github Action 将测试我的代码,构建 docker 容器并拉到 Docker Hub。 After all this I want to do rolling update to a specific swarm service.毕竟我想对特定的群服务进行滚动更新。

How can this be done?如何才能做到这一点?

So the question is how to execute the command inside GitHub Actions.所以问题是如何执行GitHub Actions里面的命令。 I would say just like any other command:我会像任何其他命令一样说:

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Execute docker swarm
        run: docker stack deploy -c compose-file.yml
        env:
          DOCKER_HOST: example.com

This requires you to expose your docker daemon to the outside world, which you should probably only do, if you have some kind of authentication in place.这要求您将 docker 守护程序暴露给外界,如果您有某种身份验证,您可能只应该这样做。 One way to do this is documented here . 此处记录了执行此操作的一种方法。 Another way would be to use SSH and execute the command on the server itself, for example with this .另一种方法是使用 SSH 并在服务器本身上执行命令,例如使用.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM