Liquibase and Docker

Hi,

I am trying to use the container version of Liquibase.  When I run the container, It exits almost immediately.  Is this by design?  Also, how would i use the updateSql command.  When I try to use it, it tells me it can not find the changelog file.  Below is the command I am using.

Thanks

docker run liquibase/liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql.jar --url=“jdbc:postgresql://host.docker.internal/Barry” --changeLogFile=dbchangelog.xml --username=postgres --password=Fender!23 generateChangeLog

thank you for responding.  so if my directory is C:\Users\MyName\Documents\LiquiBaseDocker

what would the format be?  I am on a windows machine.

Thank you very much.

Barry

Hi,

Thanks for checking in.  I got the generateChangeLog to work.  Now I am trying to get SQL files to run from the SQL directory.  its not working however.

docker run -v C:/Users/Barry.Fantle/Documents/LiquiBaseDocker:/liquibase/changelog liquibase/liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql.jar --url=“jdbc:postgresql://host.docker.internal:5432/Barry?currentSchema=Barry_sch” --defaultSchemaName=Barry_Sch --changeLogFile=/liquibase/changelog/dbchangelog.xml --username=postgres --password=pwd update

the changelog file looks like this…

<?xml version="1.1" encoding="UTF-8" standalone="no"?>

<databaseChangeLog xmlns=“http://www.liquibase.org/xml/ns/dbchangelog” 

xmlns:ext=“http://www.liquibase.org/xml/ns/dbchangelog-ext” 

xmlns:pro=“http://www.liquibase.org/xml/ns/pro” 

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” 

xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog 

http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

Any Ideas?

Thanks

Barry

Because I am mounting my windows directory for the changelog file.  I assume it finds it.  I change the include all path to “…/SQL”  i figured it would know to look in that directory as it exists in the same directory as the changefile.  

changelog c:\documents\liquibaseDocker\dbchangelog.xml

sql files c:\documents\liquibaseDocker\SQL

thoughts?

I really appreciate all you patience and help.  new issue now.  i am getting the below message

ChangeLog

<?xml version="1.1" encoding="UTF-8" standalone="no"?>

<databaseChangeLog xmlns=“http://www.liquibase.org/xml/ns/dbchangelog” 

xmlns:ext=“http://www.liquibase.org/xml/ns/dbchangelog-ext” 

xmlns:pro=“http://www.liquibase.org/xml/ns/pro” 

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” 

xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog 

http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

command - docker run -v C:/Users/Barry.Fantle/Documents/LiquiBaseDocker:/liquibase/changelog liquibase/liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql.jar --url=“jdbc:postgresql://host.docker.internal:5432/Barry?currentSchema=barry_sch” --defaultSchemaName=barry_sch --changeLogFile=/liquibase/changelog/dbchangelog.xml --username=postgres --password=pwd update

directory structure /liquibase/changelog/SQL

SQL contains .sql files.  5 have aleady been run, there is a 6th that needs to be run.

Unexpected error running Liquibase: Validation Failed:

     5 change sets check sum

          changelog/SQL/nonperson.sql::raw::includeAll was: 8:0464c5b17e02b487bb539199c0e4ed2c but is now: 8:44354c377fcd42c04402fe37c885d5fb

          changelog/SQL/person.sql::raw::includeAll was: 8:ebea1fae3863a06b5824a8e434accc5a but is now: 8:ad04d84d5c4fa8066fd89c38068bab54

          changelog/SQL/testperson.sql::raw::includeAll was: 8:4ac5330ee40926d390190feaaea9418d but is now: 8:6132d0bd1f42649b6356ab8737a9ae4c

          changelog/SQL/testperson2.sql::raw::includeAll was: 8:d08c7cf8e703038725b25e6522304637 but is now: 8:367af9b2be41c446472c6fc86133c48a

          changelog/SQL/testperson3.sql::raw::includeAll was: 8:e65fb702fae3f9a904454a8eefefc751 but is now: 8:2f651304b6f994be0921debf72df9eed

Yes, Barry1, it starts, executes Liquibase, and shutsdown. The use case is to be able to run Liquibase on a system that might not have Liquibase installed but does have Docker.

Check out the documentation here: https://hub.docker.com/r/liquibase/liquibase

I think you’ll want to make a local directory in your home directory and make it world readable. (chmod 777 ). This should allow the Liquibase Docker container create a dbchangelog.xml in that directory.

Robert

Great question!

Windows is a bit of a pain with directory permissions. I think this post spells it out pretty well: https://rominirani.com/docker-on-windows-mounting-host-directories-d96f3f056a2c

Let me know if that works for you or if you have any more quesitons. We’re here to help!

Robert

Hi, Barry! Did that work? You good? Thanks!

Robert

Roger.

Liquibase is running inside the Docker container, which is a Linux instance.So, Liquibase looks at the changelog.xml and sees it needs to run some SQL in a directory. Then, it looks for the SQL in that Windows directory and can’t find anything. After all, “C:…” doesn’t mean much in Linux land. 

I would suggest using a relative path in your path attribute and putting the directory in the same place as the changelog.xml.

Let me know if that works for you.

We also offer support for Liquibase and Liquibase Pro. You can get in touch with us here: https://download.liquibase.org/liquibase-pro-contact-us/.

Thanks!

Robert

I think that’s a good move: putting the SQL in the same directory as the changelog.xml.

If you run into more issues, please include the docker command you run, the changelog.xml, and the output. That should provide what we need to help you.

Thanks!

Robert

No problem! That’s what we do!

The good news is that you’ve solved your Docker issues. Great job! 

Now it looks like Liquibase doesn’t like the checksum’s generated by Liquibase when compared to the database.Let me get someone who knows checksums far better than me to weigh in on this thread.

Hi Barry,

My colleague Steve had the following to say (he will jump on the issue in a sec):

My suggestion would be to ask Barry if there is a chance that he modified the sql files in the path=“changelog/SQL/“ After they were already deployed and he tried to deploy (liquibase update) them again to the same database.

Would you confirm if you updated the sql files?

Thanks,

Ronak

Hi Barry,

Following up with Ronak’s message, please make sure not to modify and deploy SQL scripts that were already deployed in the same database.

Please let us know if this is true or not so we can help you find your solution.

Thanks,

Steve Z.

Thank you all for your invaluable assistance.  Looks like I got things working.

Barry

Awesome! Glad to hear it!!!

Rock on Barry!