docker network create web
cd ANY_PROJECT_DIRECTORY
docker run -itd --name web --net web --mount type=bind,src=%cd%,dst=/var/www/html/ -p 8080:80 php:8.1-apache
docker exec –it web docker-php-ext-install pdo pdo_mysql mysqli
docker exec –it web apachectl graceful
With an existing db container, you may connect it to the created network:
docker network connect web YOUR_OTHER_EXISTING_CONTAINER
**replace YOUR_OTHER_EXISTING_CONTAINER with it’s name, for instance "db" **
If you don’t already have a db container, you may create one:
docker run --name mariadb --net web --detach --env MARIADB_ROOT_PASSWORD=123 -p3306:3306 -v mariadb:/var/lib/mysql mariadb:10.3.34