sudo apt install docker docker-compose
Navigate to your desire directory and Clone the repository
git clone https://github.com/huzaifaarain/docker-php-mysql.git ./
Edit docker-compose.yml file.
mysql:
container_name: your-db-container-name
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: your-root-password
MYSQL_DATABASE: sample_db
MYSQL_USER: your-user
MYSQL_PASSWORD: your-password
ports:
- 7862:3306
services:
web:
build:
context: ./
dockerfile: ./Dockerfile
container_name: your-app-name
depends_on:
- mysql
volumes:
- ./:/var/www/html
ports:
- 7861:80
phpmyadmin:
container_name: huzaifaapp-phpmyadmin
image: phpmyadmin/phpmyadmin:latest
depends_on:
- mysql
ports:
- 7863:80
environment:
PMA_HOST: mysql-container-name
PMA_PORT: 3306
volumes:
- /sessions
FROM php:7.3-apache
RUN apt update && apt upgrade -y
RUN docker-php-ext-install your-desired-php-extensions
EXPOSE 80
RUN docker-php-ext-install mysqli ... etc
Your Application will be up and running in no time, you can access your application in browser using:
localhost:7861
localhost:7862