0

I´m trying to setup two docker container with docker-compose, using this yml:

version: '3.5'
services:
  db:
    image: mysql:5.7
    restart: always
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: abc
      MYSQL_DATABASE: shopsystem
      MYSQL_USER: shoppingsystem
      MYSQL_PASSWORD: abc
    volumes:
      - ./test.sql:/docker-entrypoint-initdb.d/test.sql
      - db_data:/var/lib/mysql
  backend:
    build:
      context: ./nodeserver
      dockerfile: Dockerfile
    image: node-test
    container_name: servernode-1
    ports:
      - 8084:8082
volumes:
  db_data: {}

The test.sql is on the root level like the docker-compose.yml

When I start the docker-compose

docker-compose up

I get the following error:

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/test.sql
ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.

I already read some threads about that problem, but I can not solved it.

I clean the volumes with the following command:

docker-compose down -v

I`m using Windows with dockertoolbox to run docker-compose.

Can someone help me?

Tos
  • 11
  • 4

1 Answers1

0
ERROR: Can't initialize batch_readline - may be the input source is a directory or a block device.

your should to map volume as directory and put test.sql file in there

 volumes:
  - myvolumes:/docker-entrypoint-initdb.d
  - db_data:/var/lib/mysql

or option 2 (if you want just a single file )

version: "3.2"    
services:
      app:
        image: app:latest
        volumes:
          - type: bind
            source: ./bla.yaml
            target: /location/bla.yaml

ref : https://docs.docker.com/storage/bind-mounts/

ref : Mount single file from volume using docker-compose

s4wet
  • 11
  • 2