H
H
HexUserHex2020-01-21 01:39:46
MySQL
HexUserHex, 2020-01-21 01:39:46

What is wrong with my docker-compose?

I'm trying to create an additional database and an admin for it in one service of my docker-compose.
But there is a syntax error in the script... I fall asleep and don't see where))

version: "3.0"
services:
   db:
    image: mysql:5.7
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=rootpass
      - MYSQL_USER=superroot
      - MYSQL_PASSWORD=superpass123
      - MYSQL_DATABASE=gitea
    entrypoint:
      sh -c "echo 'CREATE DATABASE IF NOT EXISTS nextcloud; CREATE USER 'tester'@'localhost' IDENTIFIED BY 'superpass123';\
              GRANT ALL PRIVILEGES ON * . * TO 'tester'@'localhost'; 'FLUSH PRIVILEGES'; > /docker-entrypoint-initdb.d/init.sql;\
             /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"
    #iiworks:
    #  - gitea
    volumes:
      - /var/lib/docker/volumes/mysql:/var/lib/mysql
    ports:
      - 3306:3306

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sergey, 2020-01-21
kuzmin @sergueik

HexUserHex is what you wrote in ENTRYPOINT try to run it and you will see problems with quotes around SQL.
e.g.
give
give
A = B

V
Vitaly Karasik, 2020-01-21
@vitaly_il1

I think it's easier to copy init.sql to image instead of generating it every time you run it.

A
al_gon, 2020-01-21
@al_gon

First answer: create-database-on-docker-compose-startup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question