-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
How to use host volume in OSX by docker-machine (boot2docker) #99
Comments
this comment on #44 does a good job of explaining the problem. Unfortunately, there doesn't seem to be a good solution other than storing your database files in a Docker Data Volume Container (rather than a directory on your computer) or change your Virtualbox/boot2docker configuration to have more permissive file access. |
I tried giong the data volume container route but it hit the same InnoDB error. It looks like for dev environments we will just tell our users to provision mysql using homebrew instead of bringing up a container. |
The solution is to make sure that mysql runs using the same user and group ids as your local OSX user. Create the following script:
Save it as localdb-run.sh or similar, mount it into the mysql container and use it as your starting command. |
@motin, thanks, i will try this solution at weekends. |
@dsxack Here is a sample implementation: https://github.com/neam/docker-stack/tree/develop/stacks/neam/debian-php-nginx.dna-project-base/stack |
I'd had the same error. In docker-compose.yml, (snip)
entrypoint: /localdb-run.sh
volumes:
- ./path/to/localdb-run.sh:/localdb-run.sh
(snip) This should work with docker-compose. |
@dbaba Great that it worked for you as well :) Here is a full docker-compose implementation with the script: docker-compose.yml Full explanation: Step 1: Add the script
Step 2: Change the Example:
|
@motin Thank you your script and yml works perfectly. |
Thanks @motin I know this was probably clear to everyone already but when I tried to create a container with this script I had a number of issues with permissions and adding the file. This was my solution (incase someone like me has this problem in the future).
Dockerfile FROM mysql
MAINTAINER Ian Edington "IanEdington@gmail.com"
ENV MYSQL_ROOT_PASSWORD password
ENV MYSQL_PASSWORD password
ENV MYSQL_DATABASE databasename
# this need to stay the same for script to work
ENV MYSQL_USER mysql
COPY ./localdb-run.sh /
RUN chmod 755 /localdb-run.sh
ENTRYPOINT ["/localdb-run.sh"] Build and run container docker build -t IanEdington/mysql .
docker run --name mysql -v /Users/path/to/mysql/directory:/var/lib/mysql -d IanEdington/mysql . |
Thanks @motin and @IanEdington - works great. |
thx, it does work! |
Quick note: you need to |
It works for me. I'm using a MacBook pro |
Thank you @motin - amazing fix and unblocks my efforts to improve our dev environment! |
@gharcombe-minson Great to hear :) For anyone wanting to try out an example of the workaround easily, follow the instructions on Installation and Usage on https://github.com/neam/docker-stack/tree/9a90433a3a29ca24ad93c84f76d7245528b12e63/stacks/debian-php-nginx.database/stack |
Hi, I'm getting a new error - space header page consists of zero bytes in data file ./ibdata1. Full log: db | * Working around permission errors locally by making sure that "mysql" uses the same uid and gid as the host volume Any ideas, on this? |
OK, after workarounds with deleting ibdata1. 2016-01-10 16:51:22 17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist |
@lmikelionis my guess is that there might have been an error in writing to the database earlier which is why |
Another workaround could be starting mysql as root: Add this to your Dockerfile: |
@lmikelionis I got the same error. Did you figure out what went wrong here? |
@albingeorge: solved that by changin UID: https://github.com/VilniusTechnology/docker-vtech-ci/blob/master/mysql/script/permissions.sh dont think thats possible to to in Dockerfile only, need this "helping" startup script, or smth similar... |
This image contains a fix for a permission issue in the office MySQL Docker image that prevents MySQL from running properly with Docker on MacOS: docker-library/mysql#99
This image contains a fix for a permission issue in the office MySQL Docker image that prevents MySQL from running properly with Docker on MacOS when you want to use a MacOS directory as volume to store MySQL DB files (docker-library/mysql#99)
The work around doesn't function for me, Docker 1.11.1 on OS X 10.10.5. |
The easiest work around is to get the docker for Mac beta. https://blog.docker.com/2016/03/docker-for-mac-windows-beta/ This is a direct implementation of docker on OSX, which means it has access It takes about 2 days to get the invite after requesting it here: On Sun, Jun 5, 2016 at 00:29 Dmitry notifications@github.com wrote:
|
@dmitrym0 Are you using the docker-machine-nfs available at https://github.com/adlogix/docker-machine-nfs? If not, that might be the reason for described issue... |
Ah thanks @IanEdington, requested! @viktorsteinwand I'm not sure. I know docker is hosted within a virtualbox host running on my mac. |
@dmitrym0 How does your docker-compose.yml look like? Are you using Docker Toolkit on OSX? |
@motin: I am on OSX 10.10.5, Docker 1.11.1. Here's my Dockerfile:
IanEdington above mentioned that it's working in the latest docker beta. |
As @IanEdington says, get docker for mac beta - but no invite is needed - just download it at https://docs.docker.com/docker-for-mac/ |
Has anyone else encountered this error, even with the latest Docker for Mac, after removing the entrypoint workaround and just mounting a local directory for /var/lib/mysql? |
@mozbhearsum Yes, I'm currently running into the same issue and don't know what to do. Pretty much tried everything. |
@einfallstoll @mozbhearsum Ye I'm running into that same permissions issue with mysql:5.7 – still using the older Docker Toolbox. |
No surprise that you're hitting it on Docker Toolbox - there's no native support for file sharing there. |
It works using the latest version of Docker for Mac. They got rid of these permission and ownership problems now. |
@mozbhearsum I have this problem and i'm running it on Linux, so I have no idea what is wrong |
I had the same issue before.
then in docker compose you would have something like
Hopes this helps anybody |
People using mariadb who're still having issues. Without having to use the script for user and group permissions, |
Closing given that there's not really anything we can change in the image itself and this is more of an environmental issue; see also docker-library/percona#42 (comment) (especially docker-library/percona#42). See also #161, which should allow running the image with an arbitrary |
How can i use @motin 's entry-point snippet with dockers mariadb image with vagrant? e.g
|
With your solution i got |
I use boot2docker through virtualbox via docker-machine. I seen #44, but doesn't find answer, how resolve this
docker-compose.yml:
output:
The text was updated successfully, but these errors were encountered: