title: Why did mysql data ownership change to systemd-journal-remote after running a docker container
body: <p>I have the mysql database stored in <code>/home/mysql</code> instead of <code>/var/lib/mysql</code>. The directory used to be owned by <code>mysql</code>. However, when I run the command <code>docker-compose up</code> with this yml file:</p>
  
  <pre><code>version: '3'
  services:
    mariadb:
      image: mariadb
      restart: always
      volumes:
       - /home/mysql:/var/lib/mysql
    elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
      environment:
        - "ES_JAVA_OPTS=-Xms750m -Xmx750m"
        - bootstrap.memory_lock=false
    site:
      build: .
      volumes:
        - "./app:/app"
      links:
        - mariadb:mysql
      environment:
        - DOCKER_IP=172.19.0.2
      depends_on: ['elasticsearch','mariadb']
      ports:
        - "3000:3000"
  </code></pre>
  
  <p>The docker container is able to run, but the entire folder and files in <code>/home/mysql</code> are owned by <code>systemd-journal-remote</code>, which causes the <code>node</code> server fails to connect to <code>mariadb</code>. I have to stop the docker instance, restore the mysql folder ownership and delete <code>ib_logfile0</code> and <code>ib_logfile1</code>. </p>
  
  <p>Why does mounting <code>/home/mysql</code> cause such a fatal problem?</p>
  
  <p>Update:</p>
  
  <p>My solution is to add <code>user: "mysql"</code>:</p>
  
  <pre><code>version: '3'
  services:
    mariadb:
      image: mariadb
      restart: always
      volumes:
       - /home/mysql:/var/lib/mysql
      user: "mysql"
    elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
      environment:
        - "ES_JAVA_OPTS=-Xms750m -Xmx750m"
        - bootstrap.memory_lock=false
    site:
      build: .
      volumes:
        - "./app:/app"
      links:
        - mariadb:mysql
      environment:
        - DOCKER_IP=172.19.0.2
      depends_on: ['elasticsearch','mariadb']
      ports:
        - "3000:3000"
  </code></pre>