title: Moving Wordpress site to Docker: Error establishing DB connection
body: <p>Ive been making new sites with Wordpress &amp; Docker recently and have a reasonable grasp of how it all works and Im now looking to move some established sites into Docker.</p>
  
  <p>Ive been following this guide:</p>
  
  <p><a href="https://stephenafamo.com/blog/moving-wordpress-docker-container/" rel="noreferrer">https://stephenafamo.com/blog/moving-wordpress-docker-container/</a></p>
  
  <p>I have everything setup as it should be but when I go to my domain.com:1234 I get the error message 'Error establishing a database connection'. I have changed 'DB HOST' to 'mysql' in wp-config.php as advised and all the DB details from the site Im bringing in are correct.</p>
  
  <p>I have attached to the mysql container and checked that the db is there and with the right user and also made sure the pw is correct via mysql CLI too.</p>
  
  <p>SELinux is set to permissive and I havent changed any dir/file ownership nor permissions and for the latter dirs are all 755 and files 644 as they should be.</p>
  
  <p>Edit: I should mention that database/data and everything under that seem to be owned by user/group 'polkitd input' instead of root. </p>
  
  <p>Docker logs aren't really telling me much either apart from the 500 error messages for the WP container when I browse the site on port 1234 (as expected though).</p>
  
  <p>This is the docker-compose file:</p>
  
  <pre><code>version: '2'
  
  services:
    example_db:
      image: mysql:latest
      container_name: example_db
      volumes:
        - ./database/data:/var/lib/mysql
        - ./database/initdb.d:/docker-entrypoint-initdb.d
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: password123 # any random string will do
        MYSQL_DATABASE: mydomin_db # the name of your mysql database
        MYSQL_USER: my domain_me # the name of the database user
        MYSQL_PASSWORD: password123 # the password of the mysql user
  
    example:
      depends_on:
        - example_db
      image: wordpress:php7.1 # we're using the image with php7.1
      container_name: example
      ports:
        - "1234:80"
      restart: always
      links:
        - example_db:mysql
      volumes:
        - ./src:/var/www/html
  </code></pre>
  
  <p>Suggestions most welcome as Im out of ideas!</p>