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

Image orchardup/mysql throws "ERROR: 1005 Can't create table 'db' (errno: 13)" #142

Closed
mauvm opened this issue Mar 4, 2014 · 23 comments
Closed

Comments

@mauvm
Copy link

mauvm commented Mar 4, 2014

My fig.yml:

mysql:
    image: orchardup/mysql
    ports:
        - "3306:3306"
    volumes:
        - ./mysql:/var/lib/mysql
    environment:
        MYSQL_DATABASE: laravel

And this is what I get when running fig up:

$ fig up
Creating figmysqltest_mysql_1...
Pulling image orchardup/mysql...
Attaching to figmysqltest_mysql_1
figmysqltest_mysql_1 | 140304 14:12:13 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
figmysqltest_mysql_1 | ERROR: 1005  Can't create table 'db' (errno: 13)
figmysqltest_mysql_1 | 140304 14:12:13 [ERROR] Aborting
figmysqltest_mysql_1 |
figmysqltest_mysql_1 | 140304 14:12:13 [Note] /usr/sbin/mysqld: Shutdown complete
figmysqltest_mysql_1 |

Note that I ran docker-osx destroy && docker-osx shell first.

The error isn't thrown when the volume to /var/lib/mysql isn't mounted.

Also running the container in the VM itself works perfectly fine, so it seems to be a bug in Fig.

Any idea what might cause this? I couldn't find the reason as to why the container tries to create the db table.

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

The db table is an internal MySQL thing. Presumably it's having trouble writing to that directory.

It's possible that Fig is expanding ./mysql to the wrong thing. What is your current working directory? Did it manage to create anything inside the mysql directory in there?

@mauvm
Copy link
Author

mauvm commented Mar 4, 2014

It creates the ./mysql directory as expected and places an empty mysql and test folder inside it.

So the new directory structure looks like:

mysql/
  mysql/
  test/
fig.yml

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

What does ls -al look like from both outside the VM and inside it?

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

Inside the mysql directory, that is.

@mauvm
Copy link
Author

mauvm commented Mar 4, 2014

Outside:

$ ls -la mysql
total 0
drwxr-xr-x  4 mauvm  staff  136 Mar  4 15:35 .
drwxr-xr-x  4 mauvm  staff  136 Mar  4 15:35 ..
drwxr-xr-x  2 mauvm  staff   68 Mar  4 15:35 mysql
drwxr-xr-x  2 mauvm  staff   68 Mar  4 15:35 test
$ ls -la mysql/mysql
total 0
drwxr-xr-x  2 mauvm  staff   68 Mar  4 15:35 .
drwxr-xr-x  4 mauvm  staff  136 Mar  4 15:35 ..
$ ls -la mysql/test
total 0
drwxr-xr-x  2 mauvm  staff   68 Mar  4 15:35 .
drwxr-xr-x  4 mauvm  staff  136 Mar  4 15:35 ..

And what would be the best way to test it inside the VM?

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

docker-osx ssh

How did you run the container inside the VM?

@mauvm
Copy link
Author

mauvm commented Mar 4, 2014

I know about docker-osx ssh, but am not sure how to access the /var/lib/mysql folder inside the container.

I used the following command (as mentioned in the source repo) to run the container:

docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=xehVg1IpVhEmlwRMG orchardup/mysql

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

Oh – I see what you mean. What's your working directory on your Mac? i.e. the output of pwd

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

That Docker command won't mount a volume, so this is probably a problem with Docker/docker-osx and permissions, not Fig. If you run this inside the VM:

docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=xehVg1IpVhEmlwRMG -v $CWD:/var/lib/mysql orchardup/mysql

Where $CWD is the output of pwd on the host machine, then that should help you debug further.

@mauvm
Copy link
Author

mauvm commented Mar 4, 2014

Ah ofcourse! I totally overlooked the fact that the example run command doesn't mount any folders.. Silly me.

I've tried with mounting the folder (FYI you can substitute $CWD with $(pwd) to dynamically pass the CWD) and it does work.. The mysql folder contains all kind of files:

vagrant@packer-virtualbox-iso:~$ sudo ls mysql/
columns_priv.frm  func.frm       help_keyword.frm   host.frm          proc.frm      servers.frm  time_zone.frm          time_zone_transition.frm
columns_priv.MYD  func.MYD       help_keyword.MYD   host.MYD          proc.MYD      servers.MYD  time_zone_leap_second.frm  time_zone_transition.MYD
columns_priv.MYI  func.MYI       help_keyword.MYI   host.MYI          proc.MYI      servers.MYI  time_zone_leap_second.MYD  time_zone_transition.MYI
db.frm        general_log.CSM    help_relation.frm  ndb_binlog_index.frm  procs_priv.frm    slow_log.CSM     time_zone_leap_second.MYI  time_zone_transition_type.frm
db.MYD        general_log.CSV    help_relation.MYD  ndb_binlog_index.MYD  procs_priv.MYD    slow_log.CSV     time_zone.MYD          time_zone_transition_type.MYD
db.MYI        general_log.frm    help_relation.MYI  ndb_binlog_index.MYI  procs_priv.MYI    slow_log.frm     time_zone.MYI          time_zone_transition_type.MYI
event.frm     help_category.frm  help_topic.frm plugin.frm        proxies_priv.frm  tables_priv.frm  time_zone_name.frm     user.frm
event.MYD     help_category.MYD  help_topic.MYD plugin.MYD        proxies_priv.MYD  tables_priv.MYD  time_zone_name.MYD     user.MYD
event.MYI     help_category.MYI  help_topic.MYI plugin.MYI        proxies_priv.MYI  tables_priv.MYI  time_zone_name.MYI     user.MYI

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

$(pwd) won't be pwd on the host machine though – what's pwd on your host machine?

docker-osx mounts your home directory in /Users, so the folder Fig is trying to write to is probably in there somewhere.

@mauvm
Copy link
Author

mauvm commented Mar 4, 2014

I'm used to running docker commands via SSH.. Sorry I misunderstood.

Running the docker run.. command on the host machine results in the same empty mysql and test folders and ERROR: 1005 Can't create table 'db' (errno: 13) in the logs. So it's definitely an issue when mounting..

@bfirsh
Copy link

bfirsh commented Mar 4, 2014

No worries. Could you run pwd on your host machine in the directory you're running Fig in?

@mauvm
Copy link
Author

mauvm commented Mar 4, 2014

FYI I ran:

$ mkdir ~/temp && cd $_
$ docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=xehVg1IpVhEmlwRMG -v /Users/mauvm/temp:/var/lib/mysql orchardup/mysql
$ ls -la mysql
total 0
drwxr-xr-x  2 mauvm  staff   68 Mar  4 16:07 .
drwxr-xr-x  4 mauvm  staff  136 Mar  4 16:07 ..
$ ls -la test
total 0
drwxr-xr-x  2 mauvm  staff   68 Mar  4 16:07 .
drwxr-xr-x  4 mauvm  staff  136 Mar  4 16:07 ..

And /Users/mauvm/temp is the same directory I've tested fig up in (with the earlier mentioned Fig file).

@mauvm
Copy link
Author

mauvm commented Mar 19, 2014

ping @bfirsh

@hayesgm
Copy link

hayesgm commented Mar 21, 2014

Also seeing this issue-- is there a resolution?

@mikz
Copy link

mikz commented May 21, 2014

https://bugs.launchpad.net/ubuntu/+source/mysql-5.5/+bug/1095370 happened to me (but not in this docker)

@brycereynolds
Copy link

Any updates? I have this issue as well.

@herveleclerc
Copy link

+1for me too
i have the same error with mysql build with this a docker file on mac but it's working fine on windows os

Any clue ?

FROM ubuntu:14.04
MAINTAINER Herve leclerc <herve@alterway.fr>

# Install packages
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get -y upgrade
# Add image configuration and scripts
RUN apt-get install -y mysql-server 
ADD my.cnf /etc/mysql/conf.d/my.cnf
RUN chmod 600 /etc/mysql/conf.d/my.cnf
ADD run /usr/local/bin/run
RUN chmod +x /usr/local/bin/run
VOLUME ["/var/lib/mysql"]
CMD ["/usr/local/bin/run"]

@bfirsh
Copy link

bfirsh commented Oct 28, 2014

@brycereynolds @herveleclerc Have you tried with the official image, "mysql"?

boot2docker 1.3 may also fix this problem.

@herveleclerc
Copy link

boot2docker 1.3 is not fixing problem. same problem with official mysql image
it seems that it is a permission problem. without the -v "${MYSQL_DATA}":/var/lib/mysql it works well
MYSQL_DATA=/Users/hleclerc/projects/mysql

@bfirsh
Copy link

bfirsh commented Oct 30, 2014

Maybe related to boot2docker/boot2docker#581 ?

@herveleclerc
Copy link

thanks i make it works by using vmaatta workaround :

  • create a share in virtual box i.e.: data /Users/hleclerc/projects/data
  • on vm boot2docker by adding a script /var/lib/boot2docker/bootlocal.sh with :
#!/bin/sh
/sbin/mount.vboxsf -o uid=999,gid=50 data /Users/hleclerc/projects/data >/tmp/mount.log 2>&1

By adding in my Dockerfile before getting mysql package

RUN groupadd -r mysql && useradd -r -g mysql mysql  

it creates user mysql with uid=999 et gid=999

@dnephin dnephin closed this as completed Aug 24, 2015
xulike666 pushed a commit to xulike666/compose that referenced this issue Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants