Skip to content

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

Closed
@pavel-butkevich-98

Description

@pavel-butkevich-98

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions