Bootstraping Percona Xtradb Cluster in Docker gives the error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

My goal is to get a Percona XtraDB Installation running in a Docker Container.
For this i wrote up the following configuration.

Dockerfile:

  • docker postgres with initial data is not persisted over commits
  • confluentinc kafka-zookeeper docker setup not working
  • Docker registry 2.0 API v2
  • $(pwd) - one level up
  • Can i run Internet Explorer inside a Windows Server Container?
  • Error when running artisan migrate in dockerfile
  • FROM ubuntu:wily
    ENV DEBIAN_FRONTEND noninteractive
    #
    # ENVIRONMENT INSTALL
    #
    RUN apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get install -y wget curl netcat python-dev python-setuptools python-software-properties vim
    RUN easy_install j2cli
    COPY my.cnf.j2 /templates/
    COPY docker-entrypoint.sh /
    RUN chmod +x docker-entrypoint.sh /
    #
    # PERCONA XTRADB CLUSTER INSTALL
    #
    RUN echo "deb http://repo.percona.com/apt wily main" >>     /etc/apt/sources.list.d/percona.list
    RUN echo "deb-src http://repo.percona.com/apt wily main" >>     /etc/apt/sources.list.d/percona.list
    RUN apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
    RUN apt-get update && apt-get install -y percona-xtradb-cluster-56
    ENTRYPOINT ["/docker-entrypoint.sh"]
    

    docker-entrypoint.sh

    #!/bin/bash -e
    j2 /templates/my.cnf.j2 > /etc/mysql/my.cnf
    exec bash
    

    my.cnf.j2

    [mysqld]
    user=mysql
    default_storage_engine=InnoDB
    basedir=/usr
    datadir=/var/lib/mysql
    socket=/var/run/mysqld/mysqld.sock
    innodb_autoinc_lock_mode=2
    log_queries_not_using_indexes=1
    max_allowed_packet=128M
    binlog_format=ROW
    wsrep_provider=/usr/lib/libgalera_smm.so
    wsrep_node_address={{node_ip}}
    wsrep_cluster_name="mycluster"
    wsrep_cluster_address=gcomm://
    wsrep_node_name={{node_name}}
    wsrep_sst_method=xtrabackup-v2
    wsrep_sst_auth="test:test"
    
    !includedir /etc/mysql/conf.d/
    

    wsrep_cluster_address=gcomm:// normally holds a list of 3 node WAN-IPs, i removed them due to privacy.

    Building the image works perfectly fine with:

    docker build --rm -t test .
    

    Starting works also fine with:

    docker run --name Test1 -e "node_ip=127.0.0.1" -e "node_name=Test1" -p 3306:3306 -p 4567:4567 -p 4444:4444 -p 4568:4568 -i -t test
    

    The variable node_ip points at the WAN-IP of my server, i set it to 127.0.0.1 just for privacy reasons.

    But when i try to bootstrap mysql in the container with:

    /etc/init.d/mysql bootstrap-pxc
    

    I get this error:

    2016-03-28 09:24:09 354 [Note] Server hostname (bind-address): '*'; port: 3306
    2016-03-28 09:24:09 354 [Note] IPv6 is available.
    2016-03-28 09:24:09 354 [Note]   - '::' resolves to '::';
    2016-03-28 09:24:09 354 [Note] Server socket created on IP: '::'.
    2016-03-28 09:24:09 354 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
    160328 09:24:09 mysqld_safe mysqld from pid file /var/lib/mysql/8605688929d8.pid ended
    

    How can i solve this to get the XtraDB running in my Container?

  • gcsfuse gives a Input/output error when reading or writing to mounted directory in docker
  • Specify umask in Dockerfile
  • Unable to run java Program. Error inside docker
  • Customize Docker reverse DNS
  • sed inline replacement not working from Dockerfile
  • How to restore a mongo Docker container on the Mac
  • 2 Solutions collect form web for “Bootstraping Percona Xtradb Cluster in Docker gives the error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist”


    mysql_install_db
    chown mysql.mysql -R /var/lib/mysql
    service mysql start

    The above appears to work without issue, please test it out.

    It could be a permissions problem. Try adding the following after your FROM statment:

    RUN useradd mysql \
        && mkdir /var/lib/mysql \
        && chown -R mysql:mysql /var/lib/mysql
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.