Я создаю docker compose на linux с официальными изображениями (php-apache, mariadb, phpmyadmin, portainer)
Работает хорошо
http://localhost:80 (для приложения)
http://localhost:9000 (для portainer)
http://localhost:8080/ (для phpmyadmin)
Но для доступа к базе данных с помощью phpmyadmin я получаю сообщение об ошибке
mysqli_real_connect(): (HY000/2002): php_network_getaddresses:
getaddrinfo failed: Name or service not known
другая ошибка
mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Можете ли вы помочь мне найти решение? или есть идеи?
Большое спасибо за ваши ответы
$ docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------
docker-test_apache docker-php-entrypoint apac ... Up 0.0.0.0:80->80/tcp
docker-test_mariadb docker-entrypoint.sh --def ... Up 3306/tcp
docker-test_phpmyadmin /docker-entrypoint.sh apac ... Up 0.0.0.0:8080->80/tcp
docker-test_portainer /portainer -H unix:///var/ ... Up 0.0.0.0:9000->9000/tcp
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
07be9d66e300 bridge bridge local
be235ccb569f docker-test_apache bridge local
eb025bc3e669 docker-test_backend bridge local
cbcba6b521e3 docker-test_default bridge local
415a1080b450 docker-test_frontend bridge local
e0a2e124f216 docker-test_mariadb bridge local
28e3d3b445f5 docker-test_phpmyadmin bridge local
01d4e444e990 host host local
9f4704eece00 none null local
$ docker logs docker-test_phpmyadmin
phpMyAdmin not found in /var/www/html - copying now...
Complete! phpMyAdmin has been successfully copied to /var/www/html
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.25.0.2. Set the 'ServerName' directive globally to suppress this message
мой докер-compose.yml
version: '3.7'
services:
apache:
container_name: docker-test_apache
ports:
- 80:80
environment:
- APACHE_DOCUMENT_ROOT=${APACHE_DOCUMENT_ROOT}
build:
context: .
volumes:
- .:/var/www/html/
- ./.docker/config/vhosts.conf:/etc/apache2/sites-available/000-default.conf
# - cache:/var/www/html/app/var/cache
# - log:/var/www/html/app/var/log
networks:
- apache
mariadb:
container_name: docker-test_mariadb
image: mariadb:10.2
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: sf-test
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_TCP_PORT: 3306
command: --default-authentication-plugin=mysql_native_password
networks:
- mariadb
restart: always
phpmyadmin:
container_name: docker-test_phpmyadmin
image: phpmyadmin/phpmyadmin:latest
environment:
PMA_HOST: mariadb
depends_on:
- mariadb
ports:
- 8080:80
restart: always
networks:
- phpmyadmin
portainer:
image: portainer/portainer:latest
container_name: docker-test_portainer
command: -H unix:///var/run/docker.sock
restart: always
ports:
- 9000:9000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- .docker/portainer:/data
networks:
apache:
mariadb:
phpmyadmin:
volumes:
cache:
log:
portainer_data: