Docker: Upload large sql file

0

I'm having problems with Docker. I am using Docker and docker-compose to create and configure a web environment quickly and practically. I've been a docker user for some time, but I've never had to upload a large file to a bunch of data. I am using Mysql 5.5 for compatibility in some of my projects.

I did some research and found that I could upload a .sh file from the host to the mysql container and execute whatever I wanted, but I always get the following error:

mysql: unrecognized service

My file Dockerfile

FROM php:5.6-apache
RUN docker-php-ext-install mysqli
RUN a2enmod rewrite
COPY setup.sh /mysql/setup.sh
COPY setup.sql /mysql/setup.sql
RUN /mysql/setup.sh

My file docker-compose.yml

php:
  build: .
  ports:
   - "80:80"
   - "443:443"
  volumes:
   - ./www:/var/www/html
  links:
   - mysql   
mysql:
  image: mysql:5.5
  volumes:
   - /var/lib/mysql
  environment:
   - MYSQL_ROOT_PASSWORD=1234
   - MYSQL_DATABASE=my_db

This is my file setup.sh

#!/bin/bash
set -e
service mysql start
mysql uroot -p1234 my_db < /mysql/setup.sql
service mysql stop

All goes well, the error happens in the setup.sh line: service mysql start

Thank you in advance.

    
asked by anonymous 28.04.2017 / 00:21

1 answer

0

Duke, is not it good for you to raise the dump after the machine? after the start of the container, could execute for example:

docker exec -i CONTAINER mysql -u root --password=1234 my_db < ./MySQLDump.sql

This would solve your problem in a simpler way. It allows you to better control the bank, not having to raise a dump every time you build.

    
08.06.2017 / 23:07