ERROR: Invalid argument: ./wait-for-it.sh

Viewed 1703

I have following docker compose file:

version: '3'
services:
  my_sql_conatainer_name:
    image: percona:latest
    container_name: my_sql_conatainer_name
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: secret
    ports:
    - "3306:3306"
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      timeout: 20s
      retries: 10
  migration:
    image: boxfuse/flyway:latest
    container_name: flyway_migration
    volumes:
       - ./flyway_scripts/src/main/resources/db/migration:/flyway/sql
    command: ["./wait-for-it.sh", "mysql:3306", "--", "migrate", "-url=jdbc:mysql://my_sql_conatainer_name:3306/secret?useUnicode=true&characterEncoding=utf8&useSSL=false", "-user=root", "-password=password"]

wait-for-it.sh file locates near the compose file

When I up I see following error:

flyway_migration | ERROR: Invalid argument: ./wait-for-it.sh

What do I wrong?

1 Answers

The Dockerfile for that image says:

ENTRYPOINT ["flyway"]
CMD ["-?"]

These two parts are concatenated together, and anything you type as parameters to docker run only replaces the CMD part. That is, in effect you're running flyway ./wait-for-it.sh ..., and the flyway command doesn't understand what to do with it.

If you want to continue on this path, probably your easiest next step is to write your own custom image FROM boxfuse/flyway that COPY wait-for-it.sh into the image, then adds its own entrypoint script that does the wait-for-it step and ends with exec flyway "$@".

Related