Skip to content

docker-compose environment for PHP app local development

Notifications You must be signed in to change notification settings

Greg0/php-runtime-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image build

make build image=php8.0

Docker-compose

Put your PHP application into src/ and public files (e.g. index.php) into src/public/

Makefile provides shortcuts. Argument php is optional

make start php=8.0

For xdebug images

make debug php=8.0

To stop containers

make stop

Files organization

Nginx listening for files in src/public/ on port 8080.

Composer

To run composer inside container exec

docker exec -it project_dir_php_1 composer install

or use official composer image https://store.docker.com/images/composer

Note: Official composer image is used unside php container.

Permissions in linux volumes

For fresh docker installation read Post-installation steps for Linux

To avoid permissions issues follow instructions from article "Use Linux user namespaces to fix permissions in docker volumes"

TL;DR;

Word USER in listings should be replaced by your system user name: id -u -n

  1. Create or add to existing file /etc/docker/daemon.json
{
    "userns-remap": "USER"
}
  1. Edit file /etc/subuid
USER:1000:1
USER:100000:65536
  1. Edit file /etc/subgid
USER:996:1
USER:100000:65536

Replace 996 with value returned by command getent group docker


Instead of above you can also often run

chown $(id -un) -R .

About

docker-compose environment for PHP app local development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published