Using Liquibase and PostgreSQL with Docker

Last updated: July 14, 2025

When you start a PostgreSQL database using docker run postgres, the command looks at the local system to see if the PostgreSQL Docker container already exists. If the container doesn’t exist, the command will refer to Docker Hub and download it.

To run PostgreSQL and Liquibase, your Liquibase changelog needs to be accessible to the Docker container. Mount the directory that includes the changelog file with the -v option.

Note: Enter the directory that contains your changelog in place of /home/changelog. Also, enter the hostname/ip of your database. If you are running PostgreSQL as a Docker container, use docker inspect <CONTAINER_NAME> to find the IP address of your PostgreSQL database.

docker run -v /home/changelog:/liquibase/changelog liquibase
--url=jdbc:postgresql://<DATABASE_IP>:5432/postgres
--changelog-file=/liquibase/changelog/changelog.xml --username=postgres
--password=postgres