skip to Main Content

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?

3

Answers


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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search