1

The command '/bin/sh -c mysql -u wordpress -pwordpress wordpress < /docker-entrypoint-initdb.d/wordpress.sql' returned a non-zero code: 1

My docker File :

From mysql:5.7

ENV MYSQL_ROOT_PASSWORD="************"
ENV MYSQL_USER="*******"
ENV MYSQL_PASSWORD="*********"
ENV MYSQL_DATABASE="********"

EXPOSE 3306 3366

COPY wordpress.sql /docker-entrypoint-initdb.d/.
RUN mysql -u wordpress -pwordpress wordpress < /docker-entrypoint-initdb.d/wordpress.sql
  • Hi, it may be good to also provide your wordpress.sql or the part of it that is essential for someone to understand potential issues. – Spyros K Apr 04 '19 at 11:03
  • You don't need to `RUN` anything - `.sql` in `/docker-entrypoint-initdb.d/` will be automatically executed. Note though it will only run the first time the container is generated, so make sure to remove the container and any data volume and then try restarting. Some relevant links - [example with Dockerfile](https://stackoverflow.com/questions/38504257/mysql-scripts-in-docker-entrypoint-initdb-are-not-executed), [one with docker-compose](https://stackoverflow.com/questions/53249276/docker-compose-mysql-init-sql-is-not-executed). If it still fails, maybe some problem in your sql file. – Don't Panic Apr 04 '19 at 12:35

1 Answers1

0

You don't need the last line "RUN ..."

Mysql container automatically runs whatever you copy in /docker-entrypoint-initdb.d/. This happens when you run the container, not during build.

Mihai
  • 9,526
  • 2
  • 18
  • 40