Generate a fresh Symfony application with the Docker configuration (Symfony Docker).
This project is a variant of https://github.com/jprivet-dev/symfony-starter-compose-in-another-dir.
Be sure to install the latest version of Docker Engine.
git clone [email protected]:jprivet-dev/symfony-starter.git
cd symfony-starter
make generate
:- That clone
[email protected]:dunglas/symfony-docker.git
and extract files at the root. - Build fresh images.
- Start the containers.
- Generate a fresh Symfony application at the root.
- Fix permissions.
- Show info.
- That clone
- Go on https://symfony-starter.localhost/.
All in one:
git clone [email protected]:jprivet-dev/symfony-starter.git \
&& cd symfony-starter \
&& make generate
Clean all and generate again:
make stop # 1. Stop the container
make clean # 2. Remove all generated files
make generate # 3. Generate again
make start # Start the project
make stop # Stop the project
make restart # Stop and start the project
make install # Install all (for example, after an update of your curent branch)
Run
make
to see all shorcuts for the most common tasks.
Before make generate
:
./
├── overload/
├── scripts/
├── aliases
├── LICENSE
├── Makefile
└── README.md
After make generate
:
./
├──*bin/
├──*config/
├──*docs/
├──*frankenphp/
├── overload/
├──*public/
├── scripts/
├──*src/
├──*var/
├──*vendor/
├── aliases
├──*compose.override.yaml
├──*compose.prod.yaml
├──*composer.json
├──*composer.lock
├──*compose.yaml
├──*Dockerfile
├── LICENSE
├── Makefile
├── README.md
└──*symfony.lock
(*) Fresh Symfony application with a Docker configuration
- Remove the following block from frankenphp/docker-entrypoint.sh :
# Install the project the first time PHP is started
# After the installation, the following block can be deleted
if [ ! -f composer.json ]; then
rm -Rf tmp/
composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install
# ...
fi
git add . && git commit -m "Fresh Symfony application"
You can customize the Docker build and up processes. To do this, create an overload/.env
file and override the following variables :
# overload/.env
# See https://docs.docker.com/compose/how-tos/project-name/
PROJECT_NAME=my-project
# See https://github.com/dunglas/symfony-docker/blob/main/docs/options.md#docker-build-options
COMPOSE_UP_SERVER_NAME=my.localhost
COMPOSE_UP_ENV_VARS=SYMFONY_VERSION=6.4.* HTTP_PORT=8000 HTTPS_PORT=4443 HTTP3_PORT=4443
# See https://docs.docker.com/reference/cli/docker/compose/build/#options
COMPOSE_BUILD_OPTS=--no-cache
These variables will be taken into account by the make
commands.
As the variables are common to the
Makefile
anddocker compose
, I'm not attaching an environment file with the--env-file
option at the moment. See https://docs.docker.com/compose/how-tos/environment-variables/.
On the docker compose up
, you can have the followings errors:
Error response from daemon: driver failed programming external connectivity on endpoint symfony-starter-php-1 (...): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use
Error response from daemon: driver failed programming external connectivity on endpoint symfony-starter-php-1 (...): Bind for 0.0.0.0:443 failed: port is already allocated
Overload COMPOSE_UP_ENV_VARS
in overload/.env
:
COMPOSE_UP_ENV_VARS=HTTP_PORT=8000 HTTPS_PORT=4443 HTTP3_PORT=4443
List containers using the 443
port:
docker ps | grep :443
c91d77c0994e app-php "docker-entrypoint f…" 15 hours ago Up 15 hours (healthy) 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:443->443/udp, :::443->443/udp, 2019/tcp other-container-php-1
And stop the container by ID
or by NAME
:
docker stop c91d77c0994e
docker stop other-container-php-1
It is also possible to stop all running containers at once:
make docker_stop_all
See the network statistics:
sudo netstat -pna | grep :80
tcp6 0 0 :::80 :::* LISTEN 4321/apache2
For example, in that previous case 4321/apache2
, you can stop Apache server:
sudo service apache2 stop
If you work on linux and cannot edit some of the project files right after the first installation, you can run in that project make permissions
, to set yourself as owner of the project files that were created by the docker container.
See https://github.com/dunglas/symfony-docker/blob/main/docs/troubleshooting.md
- https://symfony.com/doc/current/setup/docker.html
- https://github.com/dunglas/symfony-docker
- https://github.com/dunglas/symfony-docker/blob/main/docs/troubleshooting.md
- https://github.com/dunglas/symfony-docker/blob/main/docs/options.md#docker-build-options
- https://github.com/jprivet-dev/symfony-docker
Feel free to make comments/suggestions to me in the Git issues section.
This project is released under the MIT License.