Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Compose Update Checker

docker-check-update is a Python script to check for image updates in a Docker Compose file. It mimics some of the output and functionality of npm-check-updates.

Screenshot

Output of docker-check-update with a test docker-compose.yml

Features

  • Parses docker-compose.yml (or specified file via -c / --compose-file).
  • Fetches the latest tags for each service image from Docker Hub.
  • Determines the latest stable tag, considering semantic versioning.
  • Displays available updates in a table format, with color-coding for major, minor, and patch versions.
  • Optional: Updates the Docker Compose file in place with the new versions (-u flag).
  • Optional: Excludes specified services from checking/updating (-x or --exclude flag, supports strings, wildcards, comma-delimited lists, and /regex/).
  • Optional: Targets specific services for checking/updating by listing them as arguments.
  • Rollback: When updating, it adds a # Previous: <old_image:tag> comment above the updated image line.
  • Rollback: A --rollback flag allows reverting to the version stored in the # Previous: comment.
  • Progress bar during checks.
  • Script version display with --version.

Setup

  1. Clone the repository (or download the script):

    # If you have a git repository
    # git clone <your-repo-url>
    # cd <your-repo-directory>
  2. Ensure Python 3 is installed. (Python 3.7+ recommended)

  3. Install dependencies: The script uses requests, PyYAML, ruamel.yaml, rich, and packaging. Install them using pip:

    pip install -r requirements.txt

Usage

python docker_check_update.py [target_service1 target_service2...] [options]

Arguments & Options:

  • target_services (optional): Specific service names to check/update. If not provided, all services in the compose file are processed.
  • -c FILE, --compose-file FILE: Path to the Docker Compose file. Defaults to docker-compose.yml in the current directory.
  • -h, --help: Show the help message and exit.
  • -u, --update: Update the Docker Compose file with the latest image versions. Adds a # Previous: <old_image:tag> comment for rollback capability.
  • -x PATTERN, --exclude PATTERN: Exclude services matching the given string, wildcard (*, ?), comma-delimited list, or /regex/. Can be specified multiple times. Example: -x service1 -x '*-dev' -x '/^test-.*$/' -x 'db,cache'
  • --rollback: Roll back image versions to the one specified in # Previous: comments. This will remove the # Previous: comment after a successful rollback for that service.
  • --version: Show program's version number and exit.

Examples:

  1. Check for updates in the default docker-compose.yml:

    python docker_check_update.py
  2. Check for updates in a specific file (my-compose.yaml):

    python docker_check_update.py -c my-compose.yaml
  3. Check only specific services (api and worker) in default docker-compose.yml:

    python docker_check_update.py api worker
  4. Check and update the default docker-compose.yml in place:

    python docker_check_update.py -u
  5. Check all services in docker-compose.yml except nginx and any service ending with -debug:

    python docker_check_update.py -x nginx -x '*-debug'
  6. Update only the web service in compose.prod.yml:

    python docker_check_update.py web -c compose.prod.yml -u
  7. Roll back updated services in docker-compose.yml:

    python docker_check_update.py --rollback
  8. Check version of the script:

    python docker_check_update.py --version

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE.txt file for details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages