Running MYSQL Container - Unable to get passed Docker entrypoint


#1

I’m attempting to run an official mysql container: centos/mysql-57-centos7 on concourse to:

-create a database
-import data
-massage data
-export database
-archive

I have an issue whereby the docker container contains an ENTRYPOINT CMD of run mysql-d (https://github.com/sclorg/mysql-container/blob/master/5.7/Dockerfile#L80).

If I execute commands in the args section, these override the default CMD in the dockerfile which starts the mysql daemon and then mysql isn’t started.

run:
path: sh
args:
- -c
- |
mysql -u root -e “CREATE DATABASE FOOBAR;”

If I exec run-mysqld,it runs mysql in the foreground and them I’m stuck there.

Attempting to exec mysql to run in the background: run-mysqld & is also not successful.

Any ideas as to how to accomplish this?


#2

A bit late maybe. But I usually use Docker-compose to orchestrate things like this within a job.

The compose file would have two services, one that runs MySQL server and a second one that runs in our case a Flyway script to setup the schema. The Flyways container has a dependency define on the MySQL container so that Docker-compose will start them in the right order.

The entrypoint script of the Flyway container uses the dockerize utility to wait until the MySQL container is fully up and ready to go before kicking of Flyway.

Then in your concourse job just run docker-compose up flyway when that returns the MySQL container should have it’s schema in place.

In stead of Flyway you can run any script you that does any kind of interaction with the MySQL in the other container.
Or you can modularise the script into several different Docker images and use docker-compose to start them in the right order.