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

Container does not start up in windows host if volume mapped. #308

Closed
skyhos opened this issue May 16, 2020 · 5 comments
Closed

Container does not start up in windows host if volume mapped. #308

skyhos opened this issue May 16, 2020 · 5 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@skyhos
Copy link

skyhos commented May 16, 2020

Hi, I am trying to start Mariadb container up but it is not easy.

Host: Windows 10
Docker Desktop version: 2.3.0.2 (45183)
Mariadb Image tag: latest (2020.05.17)

Problem description
Mariadb container works fine with the following command.

docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:latest

Mariadb container does not start up if I give volume map.

docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -v D:\dockerData\mariadb\develop_on_windows\data2:/var/lib/mysql -d mariadb:latest

In the directory I can find the files newly created:
aria_log.00000001 (16KB), aria_log_control (1KB), ibdata1 (0KB)

the docker logs command prints as follow:

2020-05-16 15:13:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
2020-05-16 15:13:28+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-16 15:13:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
2020-05-16 15:13:29+00:00 [Note] [Entrypoint]: Initializing database files
2020-05-16 15:13:29 0 [ERROR] InnoDB: preallocating 12582912 bytes for file ./ibdata1 failed with error 38
2020-05-16 15:13:29 0 [ERROR] InnoDB: Could not set the file size of './ibdata1'. Probably out of disk space
2020-05-16 15:13:29 0 [ERROR] InnoDB: Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2020-05-16 15:13:30 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-05-16 15:13:30 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-05-16 15:13:30 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2020-05-16 15:13:30 0 [ERROR] Aborting

Installation of system tables failed!  Examine the logs in
/var/lib/mysql/ for more information.

The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:

    shell> /usr/bin/mysql_install_db --defaults-file=~/.my.cnf

You can also try to start the mysqld daemon with:

    shell> /usr/sbin/mysqld --skip-grant-tables --general-log &

and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell> /usr/bin/mysql -u root mysql
    mysql> show tables;

Try 'mysqld --help' if you have problems with paths.  Using
--general-log gives you a log in /var/lib/mysql/ that may be helpful.

The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
You can find the latest source at https://downloads.mariadb.org and
the maria-discuss email list at https://launchpad.net/~maria-discuss

Please check all of the above before submitting a bug report
at http://mariadb.org/jira

Please let me know if I have anything missed.
Thank you.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label May 18, 2020
@wglambert
Copy link

Using a named volume should work, you'd probably also find similar issues over at https://github.com/docker/for-win/issues

https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers#bind-mounts

These applications all require volume mapping and will not start or run correctly.
MySQL
PostgreSQL
WordPress
Jenkins
MariaDB
RabbitMQ

There's also a number of solutions in #95:

#95 (comment)

Essentially, the best solution is to put /var/lib/mysql in a volume on your Docker VM (managed via docker volume xyz commands) instead of trying to share those files directly all the way back to your Mac or Windows host filesystem.

#95 (comment)

Yeah, just use a named volume and connect it to more than one container.

#95 (comment)

using a named volume is basically the only option to keep the database files when running MariaDB on Docker for Windows since the host-shared folder presented to the container does not behave in a standard way.

#95 (comment)

We recently added #168 which should make sharing a directory from a windows host possible. Try the following (I don't have a host with Docker for Windows at the moment, but it worked when I last checked):

$ # also updated to specify a version of mariadb so that things don't break when latest becomes 10.4
$ docker run --name mariadb -d -v D:\Projects\docker\docker-qub:/var/lib/mysql -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=address -e >MYSQL_ROOT_PASSWORD=password mariadb:10.3 --innodb-flush-method=fsync

For future users that are using docker-compose it would be adding --innodb-flush-method=fsync to the command.


Going to close with what was said in that thread
#95 (comment)

Docker and MariaDB work fine together; the bit that doesn't work is the custom filesystem employed by Docker for Windows and Docker for Mac for sharing files across the VM boundary, which is not all that surprising for a database, which often use features like mmap for performance but thus also require support from the underlying filesystem. There are many reports of similar issues with vboxsf, for example.

#95 (comment)

Any fixes would have to happen either in Docker's shared filesystem or in MariaDB itself (not something we can really fix in this Docker image), so I'd recommend checking their respective upstream bugtrackers for any discussion of fixing the problem.

For further help you could also try asking the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum

@skyhos
Copy link
Author

skyhos commented May 21, 2020

@wglambert Thank you for the information.
Let me have my time.

@skyhos
Copy link
Author

skyhos commented May 23, 2020

I have tried two docker-compose configurations:

version: "3.7"
networks:
  net1:
services:
  mariadb:
    container_name: mariadb
    image: mariadb:latest
    environment:
      - MYSQL_ROOT_PASSWORD=some-pass
    ports:
      - 3306:3306
    volumes:
      - mariadb-data:/var/lib/mysql:Z
    networks:
     net1:
       aliases:
         - mariadb
volumes:
  mariadb-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /D/dockerData/mariadb/develop_on_windows/data

With the above setting, I got the same issue that I reported.

version: "3.7"
networks:
  net1:
services:
  mariadb:
    container_name: mariadb
    image: mariadb:latest
    environment:
      - MYSQL_ROOT_PASSWORD=some-pass
    ports:
      - 3306:3306
    volumes:
      - mariadb-data:/var/lib/mysql
    networks:
     net1:
       aliases:
         - mariadb
volumes:
  mariadb-data:

With the above setting, it works fine. But I want to use the first setting so that I can read the files with GUI. I suspect kind of permission problem...

@yosifkit
Copy link
Contributor

For future users that are using docker-compose it would be adding --innodb-flush-method=fsync to the command.

Did you try adding this to your first yaml?

@skyhos
Copy link
Author

skyhos commented May 31, 2020

@yosifkit No, I didn't.

However, the problem have been resolved after recent update of docker desktop.

Thank you.

@skyhos skyhos closed this as completed May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Development

No branches or pull requests

3 participants