Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create second database in existing docker image? #629

Closed
pavel-butkevich-98 opened this issue Jan 21, 2020 · 1 comment
Closed

How to create second database in existing docker image? #629

pavel-butkevich-98 opened this issue Jan 21, 2020 · 1 comment

Comments

@pavel-butkevich-98
Copy link

I'm using docker-compose file with existing pavel-local image.

version: '3.1'

services:
  mysql:
    image: pavel/pavel-local
    ports:
      - "3306:3306"
    restart: always
    volumes:
      - ./database/users-service:/docker-entrypoint-initdb.d

And I'm trying to create second database using sql file and docker-entrypoint-initdb.d.

./database/users-service/create-db.sql

CREATE DATABASE local; 

I am adding sql file with script for creating a new db to docker-entrypoint-initdb.d(container) using volumes. But it deleted sql file from docker-entrypoint-initdb.d(container) which already exist and added a new one. The old file contains information about first database. I read that volumes in docker compose delete and push new files to volume directory. How can I save old info about my first db and add a new one. Maybe without volume and docker-entrypoint-initdb.d?

@wglambert
Copy link

The docker-entrypoint-initdb.d scripts only run when the entrypoint initializes a database for you https://github.com/docker-library/docs/tree/master/mariadb#initializing-a-fresh-instance

To always run scripts you'd want a custom entrypoint like MariaDB/mariadb-docker#284 (comment)

As for your file being deleted you should ask over at the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants