hey there im learning docker currently and trying to set up a simple testing infrastructure with docker and cant seem to get it to work.
I have problems connecting to my mysql server with my phpmyadmin and with my php server.
Can someone explain what i need to do to make it work i found like 300 things online and none of them worked and now i got many tips mixed up.
version: '3.7'
volumes:
mariadb_data:
driver: local
logs:
driver: local
services:
api:
image: php:8-alpine
container_name: api
working_dir: /var/www
command: php -S 0.0.0.0:8080
environment:
docker: "true"
ports:
- "8080:8080"
volumes:
- .:/var/www
- ./logs:/var/www/logs
networks:
- web
depends_on:
- mysql
restart: always
mysql:
container_name: mysql
hostname: mysql
image: mariadb:latest
restart: always
networks:
- web
ports:
- '3306:3306'
expose:
- '3306'
command: --init-file /data/application/init.sql
environment:
MYSQL_DATABASE: 'mydb'
# So you don't have to use root, but you can if you like
MYSQL_USER: 'user'
# You can use whatever password you like
MYSQL_PASSWORD: '12345678'
# Password for root access
MYSQL_ROOT_PASSWORD: '12345678'
MYSQL_TCP_PORT: 3306
volumes:
- ./mariadb_data:/var/lib/mysql
- ./init.sql:/data/application/init.sql
phpmyadmin:
image: phpmyadmin:5.2.2
restart: always
ports:
- 9090:80
networks:
- web
environment:
MYSQL_DATABASE: 'mydb'
MYSQL_USER: user
MYSQL_PASSWORD: '12345678'
MYSQL_ROOT_PASSWORD: '12345678'
links:
- mysql:mysql
networks:
web:
# Specify driver options
driver: bridge