如何通过GitHub操作将Docker映像从Dockerhub部署到服务器
我想为我的应用程序实现CI/CD,到目前为止,我设法通过GitHub Action在Docker Hub上构建和上传图像。现在,我需要一种将该图像拉到我的VPS并运行Docker图像的方法。我不知道如何实现这一目标,我尝试了多个YouTube视频,但没有显示这一点。 有人可以将我指向正确的方向吗?
I want to implement CI/CD for my application, so far I have managed to build and upload my image on docker hub with GitHub actions. Now I need a way to pull that image on my VPS and run the docker image. I do not know how to achieve that, I tried multiple youtube videos but none show that.
Could someone point me to the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通常在dockerhub中存在图像之后的流量为:
对于NGINX的示例,该图像驻留在 dockerhub 和借助官方文档>
https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-docker/“ rel = “ 图像(在这种情况下为最新)并以Mynigninx1的名称运行容器,并将端口公开在主机80上,并将其映射到容器内部的端口80。
Usually flow after image exists in Dockerhub is:
For an example with Nginx, the image resides in Dockerhub and with help of official docs you can see
the command which will pull the Nginx image (latest in this case) and run the container with the name of mynigninx1 and expose the port on host 80 and map it to port 80 inside the container.
我所做的是:
设置a webhook 在VPS上,这是一个webhook服务器,作为webhook服务器,将端点和脚本定义为重新部署(在调用和满足端点时将执行)
What I have done is:
Setup a webhook on vps, this serves as a webhook server, define a endpoint and a script to redeploy (Will be executed when endpoint is called and met)
In your GitHub ctions flow, add new a step, send a request to this webhook server endpoint
您可以在服务器上运行一个Docker映像,以观看工作或选定的Docker容器,当有新的推送到Docker Hub注册表时,它将更新您的项目的Docker映像
它称为watch望塔
contairrrr/watch望塔
There is a docker image you can run on your server to watch your working or selected docker containers and when there is a new push to the docker hub registry then it will update your docker image of your project
Its called watchtower
containrrr/watchtower