Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not get flyway-docker to recognize local files in volumes #33

Closed
steven-ponessa opened this issue Aug 31, 2020 · 2 comments
Closed

Comments

@steven-ponessa
Copy link

I am trying to use Flyway to set up a DB2 test/demo environment in a Docker container. I have an image of DB2 running in a docker container and now am trying to get flyway to create the database environment. I can connect to the DB2 docker container and create DB2 objects and load them with data, but am looking for a way for non-technical users to do this (i.e. clone a GitHub repo and issue a single docker run command).

The Flyway Docker site (https://github.com/flyway/flyway-docker) indicates that it supports the following volumes:

Volume Description
/flyway/conf Directory containing a flyway.conf
/flyway/drivers Directory containing the JDBC driver for your database
/flyway/sql The SQL files that you want Flyway to use

I created the conf, drivers, and sql directories. In the conf directory, I placed the file flyway.conf that contained my flyway Url, user name, and password:

flyway.url=jdbc:db2://localhost:50000/apidemo
flyway.user=DB2INST1
flyway.passord=mY%tEst%pAsSwOrD

In the drivers directory, I added the DB2 JDBC Type 4 drivers (e.g. db2jcc4.jar, db2jcc_license_cisuz.jar),

And in the sql directory I put in a simple table creation statement (file name: V1__make_temp_table.sql):

CREATE TABLE EDS.REFT_TEMP_DIM (
      TEMP_ID       INTEGER  NOT NULL )
  ,   TEMP_CD       CHAR    (8)
  ,   TEMP_NM       VARCHAR (255)
  )
  DATA CAPTURE NONE 
  COMPRESS NO;

Attempting to perform the docker run with the flyway/flyway image as described in the GitHub Readme.md, it is not recognizing the flyway.conf file, since it does not know the url, user, and password.

docker run --rm -v sql:/flyway/sql -v conf:/flyway/conf -v drivers:/flyway/drivers flyway/flyway migrate


Flyway Community Edition 6.5.5 by Redgate
ERROR: Unable to connect to the database. Configure the url, user and password!

I then put the url, user, and password inline and It could not find the JDBC driver.

docker run --rm -v sql:/flyway/sql -v drivers:/flyway/drivers flyway/flyway -url=jdbc:db2://localhost:50000/apidemo -user=DB2INST1 -password=mY%tEst%pAsSwOrD migrate

ERROR: Unable to instantiate JDBC driver: com.ibm.db2.jcc.DB2Driver => Check whether the jar file is present
Caused by: Unable to instantiate class com.ibm.db2.jcc.DB2Driver : com.ibm.db2.jcc.DB2Driver
Caused by: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver

Therefore, I believe it is the way that I am setting up the local file system or associating to local files with the flyway volumes that is causing the issue. Does anyone have an idea of what I am doing wrong?

@DoodleBobBuffPants
Copy link
Contributor

Hi. You need to supply absolute paths to your volumes for docker to mount them. Here is a discussion about this and potential options.

@steven-ponessa
Copy link
Author

Thank you.

Changing the relative paths to an absolute paths fixed the volume mount issue.

docker run --rm -v /Users/steve/github-ibm/flyway-db-migration/sql:/flyway/sql -v /Users/steve/github-ibm/flyway-db-migration/conf:/flyway/conf -v /Users/steve/github-ibm/flyway-db-migration/drivers:/flyway/drivers flyway/flyway migrate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants