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.
- 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 (
-uflag). - Optional: Excludes specified services from checking/updating (
-xor--excludeflag, 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
--rollbackflag allows reverting to the version stored in the# Previous:comment. - Progress bar during checks.
- Script version display with
--version.
-
Clone the repository (or download the script):
# If you have a git repository # git clone <your-repo-url> # cd <your-repo-directory>
-
Ensure Python 3 is installed. (Python 3.7+ recommended)
-
Install dependencies: The script uses
requests,PyYAML,ruamel.yaml,rich, andpackaging. Install them using pip:pip install -r requirements.txt
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 todocker-compose.ymlin 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:
-
Check for updates in the default
docker-compose.yml:python docker_check_update.py
-
Check for updates in a specific file (
my-compose.yaml):python docker_check_update.py -c my-compose.yaml
-
Check only specific services (
apiandworker) in defaultdocker-compose.yml:python docker_check_update.py api worker
-
Check and update the default
docker-compose.ymlin place:python docker_check_update.py -u
-
Check all services in
docker-compose.ymlexceptnginxand any service ending with-debug:python docker_check_update.py -x nginx -x '*-debug' -
Update only the
webservice incompose.prod.yml:python docker_check_update.py web -c compose.prod.yml -u
-
Roll back updated services in
docker-compose.yml:python docker_check_update.py --rollback
-
Check version of the script:
python docker_check_update.py --version
This project is licensed under the GNU General Public License v3.0. See the LICENSE.txt file for details.
