Skip to content

Dockercompose trigger doesn't recognize the implicit latest tag #780

@david-uhlig

Description

@david-uhlig

Docker Compose assumes the latest tag when the image: attribute is missing a tag or digest, e.g. given

# ~/docker/proxy/compose.yaml
services:
  nginx:
    image: nginx
  labels:
    wud.watch: true
    wud.watch.digest: true
    wud.tag.include: ^latest$

The command docker compose pull nginx would pull the nginx:latest image from the Docker Hub default repository.

WUD's watcher successfully detects when the image needs updating. However, WUD's dockercompose trigger fails to pull the image and restart the container.

# ~/docker/wud/compose.yaml
services:
  whatsupdocker:
    image: getwud/wud
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ../proxy/compose.yaml:/docker/proxy/compose.yaml
    ports:
      - 3000:3000
    environment:
      # Local Docker watcher - Scan every hour
      - WUD_WATCHER_LOCAL_CRON=0 * * * *
      - WUD_WATCHER_LOCAL_SOCKET=/var/run/docker.sock
      - WUD_WATCHER_LOCAL_WATCHBYDEFAULT=false
      - WUD_TRIGGER_DOCKERCOMPOSE_PROXY_FILE=/docker/proxy/compose.yaml

This happens because in

function doesContainerBelongToCompose(compose, container) {
// Get registry configuration
const registry = getState().registry[container.image.registry.name];
// Rebuild image definition string
const currentImage = registry.getImageFullName(
container.image,
container.image.tag.value,
);
return Object.keys(compose.services).some((key) => {
const service = compose.services[key];
return service.image.includes(currentImage);
});
}

currentImage will end with the explicit :latest tag, but service.image might not, as it refers to the real value of the image attribute in the compose.yaml file. Hence, there won't be a match in L23 unless the image explicitly includes the :latest tag.

The expected behavior:

  1. WUD should pull the image and update the container, regardless of the optional :latest tag.
  2. It should not update the compose.yaml file from image: nginx to image: nginx:latest.

A temporary workaround is to explicitly add the :latest tag to all such images.

See also: #775

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions