ubuntu 22.04
file structure
docker-composer.yamlwww/Dockerfilewww/html/index.phpmysql/dbdata/
$ sudo apt update && sudo apt -y upgrade
$ sudo apt install docker-compose docker.io -y
$ vi docker-compose.yaml
version: "3.8"
services:
www:
build:
context: ./www
dockerfile: Dockerfile
depends_on:
- db
volumes:
- ./www/html:/var/www/html/
ports:
- "8080:80"
networks:
- my-network
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: xxxxxxxxx
volumes:
- ./mysql/dbdata:/var/lib/mysql/
ports:
- "3306:3306"
networks:
- my-network
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
depends_on:
- db
environment:
PMA_HOST: db
ports:
- "8081:80"
networks:
- my-network
networks:
my-network:
$ vi www/Dockerfile
FROM php:8.2-apache
ENV TZ=Asia/Bangkok
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN printf '[PHP]\ndate.timezone = "Asia/Bangkok"\n' > /usr/local/etc/php/conf.d/tzone.ini
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN apt-get update && apt-get upgrade -y
$ sudo docker-compose up -d