Search code examples
dockerdocker-composedevopscontinuous-deploymentcontinuous-delivery

deploy latest container in dokploy


I am using dokploy to deploy docker containers, but when I try to deploy a latest version of a container its not working because its not fetching the latest image from the repository

My docker file

version: '3.9'

services:
  backend:
    image: registry.gitlab.com/my-repo/my-code:latest
    container_name: backend
    ports:
      - 4000
    environment:
      NODE_ENV: development 
    restart: always

What I have already tried

  • deploy/Rebuild button in dokploy dashboard of container
  • Stop then Start the service from dokploy dashboard
  • Advance Setting in dokploy dahboard with commands
    • docker pull registry.gitlab.com/my-repo/my-code:latest && docker compose -p ecom-backend-z9r6tk -f docker-compose.yml up -d --build --remove-orphans
    • docker compose -p ecom-backend-z9r6tk -f docker-compose.yml up -d --build --remove-orphans --pull

Hacks that are working but I don't want to use, I want to automate the process

  • If I change the image tag from latest to a specify number while building the image and docker compose file everytime I publish a new version its working fine
  • SSH into server and manually pull the latest image

Solution

  • Set pull_policy to always like this

    version: '3.9'
    
    services:
      backend:
        image: registry.gitlab.com/my-repo/my-code:latest
        pull_policy: always
        container_name: backend
        ports:
          - 4000
        environment:
          NODE_ENV: development 
        restart: always
    

    and compose will pull the image when you do docker compose up.

    Documentation here.