Skip to content

Instantly share code, notes, and snippets.

@vhugo
Last active February 27, 2016 01:42
Show Gist options
  • Save vhugo/01b0dd227c08e687e0cf to your computer and use it in GitHub Desktop.
Save vhugo/01b0dd227c08e687e0cf to your computer and use it in GitHub Desktop.

Revisions

  1. vhugo revised this gist Feb 27, 2016. 3 changed files with 4 additions and 9 deletions.
    5 changes: 2 additions & 3 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@ FROM mysql:5.5.44

    VOLUME /var/lib/mysql

    COPY ./docker-permfix.sh /permfix.sh
    RUN chmod 755 /permfix.sh
    RUN usermod -u 1000 mysql

    CMD ["/permfix.sh"]
    CMD ["/entrypoint.sh", "mysqld", "--user=mysql", "--datadir=/var/lib/mysql"]
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -8,3 +8,5 @@ When trying to add a volume to a container for a [MySQL Docker](https://github.c
    docker run -d --name mysql-5.5.44 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=somepassword4R00T \
    -v /Users/your_user/data/mysql:/var/lib/mysql your_user/mysql
    ```

    If you already have data, you might not need `-e MYSQL_ROOT_PASSWORD=somepassword4R00T` as part of the command.
    6 changes: 0 additions & 6 deletions docker-permfix.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    #!/bin/bash
    # Working around to solve permission issue with Mac OSX
    # when the hosting volume for data.
    set -e
    usermod -u 1000 mysql
    exec /entrypoint.sh mysqld --user=mysql --datadir=/var/lib/mysql
  2. vhugo revised this gist Feb 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ When trying to add a volume to a container for a [MySQL Docker](https://github.c
    ## Using this thing
    - download `Dockerfile` and `docker-permfix.sh`
    - in you Terminal, go to the directory you have these files and run `docker build -t your_user/mysql .`
    - the run this to create your container:
    - then to create your container, run this:
    ```
    docker run -d --name mysql-5.5.44 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=somepassword4R00T \
    -v /Users/your_user/data/mysql:/var/lib/mysql your_user/mysql
  3. vhugo revised this gist Feb 26, 2016. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,10 @@
    When trying to add a volume to a container for a docker mysql on Mac OSX, I was having permission issues to create the database files.
    I solved by creating a new image based on the docker mysql image to fix the issue before running the server.
    Got the idea from [this comment](https://github.com/boot2docker/boot2docker/issues/581#issuecomment-62491280)
    When trying to add a volume to a container for a [MySQL Docker](https://github.com/dockerfile/mysql) on Mac OSX, I had permission issues to create the database files. I create a new image based on the [MySQL Docker](https://github.com/dockerfile/mysql) image to fix the issue before running the server. Got the idea from [this comment](https://github.com/boot2docker/boot2docker/issues/581#issuecomment-62491280) and [this other one](https://github.com/docker-library/mysql/issues/99#issuecomment-152655145)

    ## Using this thing
    - download `Dockerfile` and `docker-permfix.sh`
    - in you Terminal, go to the directory you have these files and run `docker build -t your_user/mysql .`
    - the run this to create your container:
    ```
    docker run -d --name mysql-5.5.44 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=somepassword4R00T \
    -v /Users/your_user/data/mysql:/var/lib/mysql your_user/mysql
    ```
  4. vhugo created this gist Feb 26, 2016.
    8 changes: 8 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    FROM mysql:5.5.44

    VOLUME /var/lib/mysql

    COPY ./docker-permfix.sh /permfix.sh
    RUN chmod 755 /permfix.sh

    CMD ["/permfix.sh"]
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    When trying to add a volume to a container for a docker mysql on Mac OSX, I was having permission issues to create the database files.
    I solved by creating a new image based on the docker mysql image to fix the issue before running the server.
    Got the idea from [this comment](https://github.com/boot2docker/boot2docker/issues/581#issuecomment-62491280)

    6 changes: 6 additions & 0 deletions docker-permfix.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/bin/bash
    # Working around to solve permission issue with Mac OSX
    # when the hosting volume for data.
    set -e
    usermod -u 1000 mysql
    exec /entrypoint.sh mysqld --user=mysql --datadir=/var/lib/mysql