我正在使用官方映像(php-apache,mariadb,phpmyadmin,portainer)在linux上创建docker compose
运行良好
http://localhost:80(对于应用程序)
http://localhost:9000(面向讲师)
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日志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
我的docker-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: