title: How to run Percona XtraDB Cluster with external data directory?
body: <p>When I run <strong><a href="https://hub.docker.com/r/percona/percona-xtradb-cluster/" rel="nofollow noreferrer">Percona XtraDB Cluster</a></strong> with external data directory (I try to restore from backup made with <a href="https://www.percona.com/doc/percona-xtrabackup/2.4/index.html" rel="nofollow noreferrer">Percona XtraBackup</a>), I have error:</p>
  
  <pre><code>--initialize specified but the data directory has files in it. Aborting.
  </code></pre>
  
  <p>How can I fix it?</p>
  
  <p><strong>Docker command:</strong></p>
  
  <pre><code>docker run --name xtradb_from_backup -p 3307:3306 \
  -e MYSQL_ROOT_PASSWORD=1 -e XTRABACKUP_PASSWORD=2 \
  -e CLUSTER_NAME=xtradb -d -v ~/mysql/:/etc/mysql/conf.d \
  -v /db:/var/lib/mysql percona/percona-xtradb-cluster:5.7.16 \
  --pxc_strict_mode=PERMISSIVE;
  </code></pre>
  
  <p>Also I have tried omit <code>MYSQL_ROOT_PASSWORD</code> according to <a href="https://hub.docker.com/r/percona/percona-server/" rel="nofollow noreferrer">documentation</a>:</p>
  
  <pre><code>docker run --name xtradb_from_backup -p 3307:3306 \
  -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e XTRABACKUP_PASSWORD=2 \
  -e CLUSTER_NAME=xtradb -d -v ~/mysql/:/etc/mysql/conf.d \
  -v /db:/var/lib/mysql percona/percona-xtradb-cluster:5.7.16 \
  --pxc_strict_mode=PERMISSIVE;
  </code></pre>
  
  <p><strong>Error log:</strong></p>
  
  <pre><code>Running --initialize-insecure on /var/lib/mysql/
  total 345M
  drwxrwxr-x  7 1001 root 4.0K Apr 13 14:53 .
  drwxr-xr-x 19 root root 4.0K Dec 15 21:40 ..
  -rw-r-----  1 1001 root   56 Apr 13 09:28 auto.cnf
  ...
  -rw-r-----  1 1001 root 3.8M Apr 13 14:27 xb_doublewrite
  -rw-r--r--  1 1001 root   23 Apr 13 09:14 xtrabackup_binlog_info
  -rw-r--r--  1 1001 root   23 Apr 13 10:23 xtrabackup_binlog_pos_innodb
  -rw-rw----  1 1001 root  123 Apr 13 10:23 xtrabackup_checkpoints
  -rw-r--r--  1 1001 root   46 Apr 13 09:14 xtrabackup_galera_info
  -rw-rw----  1 1001 root  549 Apr 11 00:34 xtrabackup_info
  -rw-rw----  1 1001 root 158M Apr 13 09:14 xtrabackup_logfile
  2017-04-13T14:53:02.875351Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
  2017-04-13T14:53:02.875413Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
  2017-04-13T14:53:02.875473Z 0 [Warning] WSREP: Node is running in bootstrap/initialize mode. Disabling pxc_strict_mode checks
  2017-04-13T14:53:02.877589Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
  2017-04-13T14:53:02.877618Z 0 [ERROR] Aborting
  </code></pre>