title: MYSQL docker file
body: <p>I have a mysql docker file as follows:</p>
  
  <pre><code>FROM mysql:latest
  
  ENV MYSQL_ROOT_PASSWORD password
  ENV MYSQL_DATABASE database
  ENV MYSQL_USER root  
  ENV MYSQL_PASSWORD mysql007
  ENV COMPOSE_CONVERT_WINDOWS_PATHS 1
  
  COPY init.sql /docker-entrypoint-initdb.d/
  
  RUN chmod a+x /docker-entrypoint-initdb.d/init.sql &amp;&amp; chown root:root     /docker-entrypoint-initdb.d/init.sql
  
  EXPOSE 3306
  CMD ["mysqld"]
  </code></pre>
  
  <p>I build the file using the following command on docker terminal:</p>
  
  <pre><code>docker build --build-arg http_proxy=&lt;value&gt; --build-arg https_proxy=&lt;value&gt; -f mySQL_Dockerfile -t mysql .
  </code></pre>
  
  <p>Whenever I run the docker file it gives me the following log and exits:</p>
  
  <pre><code>Initializing database
  2017-03-14T08:58:57.139375Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2017-03-14T08:58:57.538155Z 0 [Warning] InnoDB: New log files created, LSN=45790
  2017-03-14T08:58:57.667334Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  2017-03-14T08:58:57.726216Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 757aecb4-0894-11e7-9b9f-0242
  ac110002.
  2017-03-14T08:58:57.729630Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2017-03-14T08:58:57.732463Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
  2017-03-14T08:59:02.299741Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:02.299874Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:02.299916Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:02.299950Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:02.300070Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
  Database initialized
  Initializing certificates
  Generating a 2048 bit RSA private key
  .....+++
  .......................................+++
  unable to write 'random state'
  writing new private key to 'ca-key.pem'
  -----
  Generating a 2048 bit RSA private key
  ...............+++
  ..........+++
  unable to write 'random state'
  writing new private key to 'server-key.pem'
  -----
  Generating a 2048 bit RSA private key
  ..............................+++
  ............+++
  unable to write 'random state'
  writing new private key to 'client-key.pem'
  -----
  Certificates initialized
  MySQL init process in progress...
  2017-03-14T08:59:05.114256Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2017-03-14T08:59:05.118407Z 0 [Note] mysqld (mysqld 5.7.17) starting as process 77 ...
  2017-03-14T08:59:05.121736Z 0 [Note] InnoDB: PUNCH HOLE support available
  2017-03-14T08:59:05.121870Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  2017-03-14T08:59:05.121904Z 0 [Note] InnoDB: Uses event mutexes
  2017-03-14T08:59:05.121942Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  2017-03-14T08:59:05.121958Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
  2017-03-14T08:59:05.121974Z 0 [Note] InnoDB: Using Linux native AIO
  2017-03-14T08:59:05.122514Z 0 [Note] InnoDB: Number of pools: 1
  2017-03-14T08:59:05.122715Z 0 [Note] InnoDB: Using CPU crc32 instructions
  2017-03-14T08:59:05.124223Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  2017-03-14T08:59:05.135947Z 0 [Note] InnoDB: Completed initialization of buffer pool
  2017-03-14T08:59:05.137985Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
  2017-03-14T08:59:05.150094Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  2017-03-14T08:59:05.161065Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  2017-03-14T08:59:05.161215Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  2017-03-14T08:59:05.337319Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  2017-03-14T08:59:05.341242Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  2017-03-14T08:59:05.341492Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  2017-03-14T08:59:05.345441Z 0 [Note] InnoDB: Waiting for purge to start
  2017-03-14T08:59:05.395911Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 2534561
  2017-03-14T08:59:05.397917Z 0 [Note] Plugin 'FEDERATED' is disabled.
  2017-03-14T08:59:05.405692Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
  2017-03-14T08:59:05.431196Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
  2017-03-14T08:59:05.431990Z 0 [Warning] CA certificate ca.pem is self signed.
  2017-03-14T08:59:05.434311Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170314  8:59:05
  2017-03-14T08:59:05.444568Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:05.444699Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:05.444743Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:05.444773Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:05.446269Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:05.451149Z 0 [Note] Event Scheduler: Loaded 0 events
  2017-03-14T08:59:05.451397Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-parti
  tion-engine-check' to skip this check.
  2017-03-14T08:59:05.451433Z 0 [Note] Beginning of list of non-natively partitioned tables
  2017-03-14T08:59:05.460184Z 0 [Note] End of list of non-natively partitioned tables
  2017-03-14T08:59:05.460451Z 0 [Note] mysqld: ready for connections.
  Version: '5.7.17'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
  Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
  Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
  Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
  2017-03-14T08:59:08.290703Z 5 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:08.290960Z 5 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:08.291016Z 5 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:08.291115Z 5 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
  2017-03-14T08:59:08.291157Z 5 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
  mysql: [Warning] Using a password on the command line interface can be insecure.
  mysql: [Warning] Using a password on the command line interface can be insecure.
  ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'@'%'
  </code></pre>
  
  <p>Any idea what the problem could be? It says the root user creation failed and exits!</p>
  
  <p>Thanks.</p>