Well, that didn't take long! The other day I wrote an article about updating all my docker containers forcefully and in batches, and yesterday I decided to take a shot at Ouroboros to do more targeted container updates in order to reduce downtime and generally get a cleaner setup. I didn't regret the effort!

First, I fired up ouroboros with this simple docker-compose configuration:

  ouroboros:
    container_name: ouroboros
    hostname: ouroboros
    image: pyouroboros/ouroboros
    environment:
      - CLEANUP=true
      - INTERVAL=30
      - LOG_LEVEL=info
      - SELF_UPDATE=true
      - TZ=Europe/Oslo
      - NOTIFIERS="mailtos://google-username:google-app-password@gmail.com?to=email@example.com"
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Straight out of the box, Ouroboros notified me by mail that it was starting up, it began checking my base images against remote Docker registries and notified me by email of every update it was doing to my containers. Kind of like magic.

However, I noticed that the ouroboros-container was giving me some critical error messages in its log:

2019-04-07 23:09:48 : CRITICAL : dockerclient : Couldn't pull. Skipping. Error: 404 Client Error: Not Found ("pull access denied for simple-apache-php, repository does not exist or may require 'docker login'")

I soon figured out this was happening because I was building the simple-apache-php container from a Docker-file, and not simply using a pre-built image from a Docker registry. I concluded that was in need of my own Docker registry to put home cooked base images. I started out with a locally available registry like this:

  myregistry:
    container_name: myregistry
    image: registry:2
    ports:
      - "5000:5000"
    volumes:
      - ${MY_DOCKER_DATA_DIR}/registry:/var/lib/registry

This way the images will be persistent and I can easily back them up regularly and restore if needed. After firing up my newly created Docker registry, I built and pushed my home cooked simple-apache-php base image to the local Docker registry like this:

/usr/bin/docker build -t simple-apache-php ${BASE_DIR}/simple-apache-php/.
/usr/bin/docker tag simple-apache-php localhost:5000/simple-apache-php:latest
/usr/bin/docker push localhost:5000/simple-apache-php:latest

I run these commands within a cron-job every night, along with some sanity checking and remote registry image pulling to assure that my manually built images also use the latest base Images defined in the various Docker files.

When the image was stored in my local Docker registry, I could start referencing it in my docker-compose.yml, instead of using the build directive:

image: localhost:5000/simple-apache-php:latest

This way, Ouroboros was fully capable of updating my custom containers too!

One a side note I feel I should mention that when I omitted tagging my images explicitly, I got the following error from Ouroboros:

2019-04-07 23:05:52 : ERROR : dockerclient : Issue detecting simple-apache-php's image tag. Skipping...

In my case, this was solved by adding the ":latest" tag in the tagging and pushing of my images.

If you want to check out my setup, see The aweome garage on GitHub.

Previous Post Next Post