To create a basic PHP and MySQL setup with docker create a project with the following structure:
.
├── docker-compose.yml
└── www
└── index.php
Write some code in your php code and then add the following content in docker-compose.yml
file:
version: '3'
services:
php:
image: registry.gitlab.com/kisphp/ci-registry/php7.4:latest
working_dir: /project
volumes:
- ./:/project
networks:
- default
ports:
- "8080:8080"
links:
- mysql
command: "php -S 0.0.0.0:8080 -t /project/web"
mysql:
image: mysql:5.6
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: kisphp
MYSQL_USER: kisphp
MYSQL_PASSWORD: kisphp
MYSQL_ROOT_PASSWORD: kisphp
Now, make sure you have docker daemon started and then run the following command:
docker-compose up
# you can run the command in background
docker-compose up -d
After docker compose finishes, you can access the project at url: http://localhost:8080