Unable to start Mysql in a Dockerfile when executing CMD script

Viewed 2959

I'm unable to start mysql demon when executing mysqld in a bash script at the end of my Dockerfile width CMD [ "./myscript.sh" ]. However, CMD [ "mysqld" ] works.

Dockerfile

FROM mysql:5.7
USER mysql
COPY ./setconf.sh .
COPY config/my.cnf /etc/mysql/conf.d
CMD [ "./setconf.sh" ]

# CMD ["mysqld"]
# This command works ! 

I'm getting this error:

[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to         create it
[ERROR] Fatal error: Can't open and lock privilege tables: Table     'mysql.user' doesn't exist

docker-compose.yml

  mysql:
    build: mysql
    environment:
      MYSQL_PASSWORD: pass
      MYSQL_ROOT_PASSWORD: pass
      HOST: mysql
      MYSQL_ROOT_HOST: mysql
    ports:
         - "3306:3306"

./setconf.sh

mysqld

Note:

  • I'm doing docker-compose down at every try
  • I need special options to run mysql

my.cnf

[mysqld]
default-storage-engine = INNODB
sql-mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
transaction-isolation = READ-COMMITTED
innodb_flush_log_at_trx_commit = 1
init_connect = "set session autocommit=0"
log_bin_trust_function_creators = 1
max_sp_recursion_depth = 100
lower_case_table_names = 1
thread_stack = 256K
max_allowed_packet = 16M

Check the Detailled docker-compose logs

2 Answers
Related