0

I am trying to set up a learning environment (wordpress) with docker compose and when I run my compose file I get the following message from Apache:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.80.3. Set the 'ServerName' directive globally to suppress this message

Every time I run the compose I get a diffent IP to access my wordpress. Based on what I saw here, I should pass the domain name using the directive "hostname".

When I do this, I get the same message above but with the IP: 127.0.0.1. I checked the /etc/hosts of the wordpress image and there was indeed the localhost entry there but when I enter this IP or "localhost" in my browser, I get nothing. Any Idea how I could solve this prob lem? This is my compose file:

version: "3.3"
services:
    db:
        container_name: wordpress_db
        image: mysql:5.7
        restart: always
        volumes:
            - /media/mjgoncalves/9e8c57d5-0fca-4e64-9adb-673a13616728/development/docker/wordpress/frescorestaurante/mysql:/var/lib/mysql
        ports:
            - 18766:3306
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    wordpress:
        container_name: local_wordpress
        image: wordpress:latest
        hostname: localhost
        restart: always
        ports: 
            - 8000:80
        depends_on:
        - db
        environment:
            WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
            WORDPRESS_DB_USER: ${MYSQL_USER}
            WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
            WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
    phpmyadmin:
        container_name: phpmyadmin
        image: phpmyadmin/phpmyadmin:latest
        hostname: localhost
        restart: always
        ports:
            - 9000:80
        depends_on:
        - db
        - wordpress
        environment:
            PMA_HOST: db
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            DOCKER_COMPOSE_YML_LOCATION: ${PWD}
Tiago
  • 1
  • 1
  • 1
    You can just change hostname: localhost to hostname: wordpress and you should always be able to access it via http://wordpress on your host or by http://localhost:8000 – Terry Sposato Feb 22 '21 at 05:36
  • Thanks. it worked man! I don't understand exactly the logic behind it. I would be glad if you could explain me that, @TerrySposato but explaining it or not, please post the solution as an answer so that I can accept it. Thanks once again! – Tiago Feb 22 '21 at 15:08

0 Answers0