Based on: https://github.com/ucrem/docker-laravel-angular public template
A just installed backend container with:
- Laravel 11
- PHP 8.3
- OPTIONAL: Zscaler certificate
A mysql container with official mysql: latest dockerhub image
A phpmyadmin container with the official dockerhub image phpmyadmin / phpmyadmin, linked to the mysql container in order to access the DB
A nginx webserver container with the official image of the dockerhub nginx: alpine
The /docker/backend/supervisor/supervisord.conf file is linked in the backend container. Editing that file is instantly replicated to the container
To begin the installation, follow these steps:
Copy the .env.example
file to create your own environment configuration file. This file will be used to set up the project and the database user for MySQL:
cp .env.example .env
If you are using Zscaler, you need to install the Zscaler root certificate in WSL (Windows Subsystem for Linux). Zscaler intercepts SSL connections, terminating them at its end and creating a new SSL connection to the destination using its own certificate. To enable WSL to connect with this relayed connection, you must install a copy of the Zscaler root certificate.
- Export a copy of the certificate from the Windows certificate store:
- Open
certmgr.msc
. - In the left-hand panel, click on "Trusted Root Certification Authorities".
- In the right-hand panel, scroll down to the entry "Zscaler Root CA".
- Right-click on it and select "All Tasks -> Export...".
- Choose "Base-64 encoded X.509 (.cer)".
- Rename the exported file from
.cer
to.crt
. - Place the
cacert.crt
file into the/docker/backend
folder. - Uncomment the relevant lines in
/docker/backend/php.ini
. - Uncomment the relevant lines in
docker-compose.yml
.
Next, build the Docker containers:
docker-compose build
Wait for the configuration process to complete. Then start the containers:
docker-compose up -d
Once all the containers are initialized, connect to the backend container:
docker exec -it PROJECT_NAME_backend /bin/bash
If you did not change the project name, use:
docker exec -it brewery_backend /bin/bash
You will be in the /var/www/backend
directory.
Proceed by copying the .env.example
file again and updating it with the same MySQL database name, user, and password as in the Docker instance:
cp .env.example .env
Then, install all dependencies:
composer install
Generate the application key and run the database migrations with seed:
php artisan jwt:secret
php artisan jwt:generate-certs
php artisan key:generate
php artisan migrate --seed
So here are the links currently configured:
backend: localhost:8000
phpmyadmin: localhost:7000
First, list all Docker images to identify the build you want to delete. Use the following command:
docker images
This command will display a list of all images with their corresponding image IDs, repository names, tags, and sizes.
From the list of images, identify the image you want to delete. Note down the IMAGE ID
or REPOSITORY:TAG
of the target image.
To delete a specific Docker image, use the following command:
docker rmi <IMAGE ID or REPOSITORY:TAG>
or
docker rmi myapp:latest
If the image is being used by a stopped container, you may encounter an error. To force delete the image, use the -f
flag:
docker rmi -f <IMAGE ID or REPOSITORY:TAG>
Sometimes, you may also want to remove containers associated with a build. First, list all containers:
docker ps -a
This command will display a list of all containers, including stopped ones, with their corresponding container IDs and names.
To delete a specific Docker container, use the following command:
docker rm <CONTAINER ID or NAME>
Replace <CONTAINER ID or NAME>
with the appropriate value. For example:
docker rm 1a2b3c4d5e6f
or
docker rm mycontainer
To clean up all unused images, containers, volumes, and networks, you can use the docker system prune
command. This is useful to free up disk space:
docker system prune -a
You will be prompted to confirm the action. Type y
and press Enter.
-
Check Disk Usage: To see how much disk space Docker is using, you can use the following command:
docker system df
-
Remove Dangling Images: Dangling images are layers that are not tagged and are not referenced by any container. To remove them, use:
docker image prune