如何通过GitHub操作将Docker映像从Dockerhub部署到服务器

发布于 2025-01-25 15:10:47 字数 156 浏览 2 评论 0原文

我想为我的应用程序实现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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小…楫夜泊 2025-02-01 15:10:47

通常在dockerhub中存在图像之后的流量为:

对于NGINX的示例,该图像驻留在 dockerhub 和借助官方文档>

docker run --name mynginx1 -p 80:80 -d nginx

https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-docker/“ rel = “ 图像(在这种情况下为最新)并以Mynigninx1的名称运行容器,并将端口公开在主机80上,并将其映射到容器内部的端口80。

Usually flow after image exists in Dockerhub is:

  • you use the docker login command to log in to the user which has permissions to pull the image
  • You can either pre pull the image using the docker pull command or you can straight on just use the docker run command and it will pull the image if not existing and run it.

For an example with Nginx, the image resides in Dockerhub and with help of official docs you can see

docker run --name mynginx1 -p 80:80 -d nginx

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.

心欲静而疯不止 2025-02-01 15:10:47

我所做的是:

  1. 设置a webhook 在VPS上,这是一个webhook服务器,作为webhook服务器,将端点和脚本定义为重新部署(在调用和满足端点时将执行)

  2. ,添加新步骤,将请求发送到此Webhook Server endpoint

What I have done is:

  1. 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)

  2. In your GitHub ctions flow, add new a step, send a request to this webhook server endpoint

美人骨 2025-02-01 15:10:47

您可以在服务器上运行一个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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文