I am new to docker. I am on a windows 7 machine and using docker toolbox. I am trying to write a docker-compose.yml for MySQL which creates a database and runs 2 scripts (create table and insert)
version: '3'
services:
mysql-image:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: myDatabase
MYSQL_USER: test
MYSQL_PASSWORD: pwtest
ports:
- "3306:3306"
volumes:
- ./sqlscripts/:/docker-entrypoint-initdb.d/
volumes:
sqlscripts:
I can connect to the database, but the problem I have is running the scripts. mostly I run into the following error:
mysql-image_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
mysql-image_1 | ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device. docker_mysql-image_1 exited with code 1
I searched for a while, trying to get it work but at this point I do not know what I am doing wrong. This is one of my .sql scripts which I am trying to run it when the docker container starts. createTablePerson.sql
CREATE TABLE `myDatabase`.`Person` (
`idPerson` INT NOT NULL AUTO_INCREMENT,
`Name` VARCHAR(45) NOT NULL,
`age` INT NOT NULL,
PRIMARY KEY (`idPerson`));
Thanks.