Use Custom Policy Checks with Docker

Last updated: July 14, 2025

__Note__: This tutorial is only applicable to Liquibase 4.29.0–4.30.0. In Liquibase 4.31.0 and later, the configuration steps on this page are deprecated: you can simply install the Liquibase Docker image and use Custom Policy Checks.

This tutorial shows you how to configure Docker and Liquibase to deploy Liquibase Pro Custom Policy Checks. This helps isolate your Python scripts, minimizing conflicts with other applications on your machine.

Before you begin

Procedure

1

Install Docker image

1. In your command line, install the official Liquibase Docker image.

docker pull liquibase

2. Install the Liquibase Checks extension.

  • Liquibase 4.31.0 and later: the checks extension is pre-installed in your image.

  • Liquibase 4.30.0 or earlier: you must manually add the checks extension to your image.

lpm add liquibase-checks

For more information, see Using Liquibase and Docker.

2

Configure Docker image

1. In your Dockerfile, set necessary permissions.

USER root

2. On Linux, set the XDG_CACHE_HOME environment variable to any directory that exists and you have write permissions for.

XDG_CACHE_HOME=/tmp

3. (Optional) Create a Python Virtual Environment. Liquibase includes a built-in virtual environment in the checks extension JAR. The built-in environment contains Liquibase Python Modules and the modules simplejson, sqlparse, and urllib3. However, if you want to install additional Python libraries, you must create your own virtual environment.

3

Create and run your checks

1. Follow the steps in Create a Custom Policy Check to write a basic Python check and configure it in the Liquibase checks framework.

2. Run the Liquibase checks run command. Ensure that you specify all necessary parameters.

For example:

docker run -e "LIQUIBASE_LOG_LEVEL=DEBUG" --network=host --rm -v /home/liquibase-project:/liquibase/changelog --user=root liquibase/liquibase --search-path=/liquibase/changelog checks run --url=jdbc:mysql://mysql-db.us-east-1.rds.amazonaws.com:3306/db --password=xxx --username=admin --changelog-file=changelog.xml --checks-scope=changelog,database --checks-settings-file=/liquibase/changelog/liquibase.checks-settings.conf --checks-scripts-enabled=true --checks-scripts-path=/liquibase/changelog

Use Custom Policy Checks with Docker - Liquibase