For Laravel you must change the php version found in the folder:
.docker> php-fpm-alpine > DockerfileDeve ser alterado apenas o
ARG PHP_VERSION=8.1.1 for
ARG PHP_VERSION=8.0- Docker. See https://docs.docker.com/engine/installation
- Docker compose. See docs.docker.com/compose/install
Use laravel github and select the latest version.
git clone [email protected]:laravel/laravel.git srcClimbing the container
docker-compose up -dIn your terminal type the following commands
1: docker-compose exec php-fpm cp .env.example .env
2: docker-compose exec php-fpm composer install
3: docker-compose exec php-fpm chown -R www-data:www-data /application/storage
4: docker-compose exec php-fpm php artisan key:generateNo docker-compose.yml file, in the mariadb service is the user, password and bank name settings. Copy the information to the .env.
Access phpmyadmin in host: localhost; port: 31003 and create the table as the name is in docker-compose.yml.
HOST=mariadb
DATABASE=MYSQL_DATABASE
USERNAME=root
PASSWORD=MYSQL_ROOT_PASSWORDDB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=MYSQL_DATABASE
DB_USERNAME=root
DB_PASSWORD=MYSQL_ROOT_PASSWORDdocker-compose exec php-fpm php artisan migrateIf you have problems saving the .env information, follow the steps below:
1: docker-compose exec php-fpm sh
2: chmod -R 777 .env
3: exitYou can access your application via localhost. Mailhog and nginx both respond to any hostname, in case you want to add your own hostname on your /etc/hosts
| Service | Address outside containers |
|---|---|
| Webserver | localhost:31000 |
| MariaDB | host: localhost; port: 31003 |
You'll need to configure your application to use any services you enabled:
| Service | Hostname | Port number |
|---|---|---|
| php-fpm | php-fpm | 9000 |
| MariaDB | mariadb | 3306 (default) |
| Redis | redis | 6379 (default) |
Note: you need to cd first to where your docker-compose.yml file lives.
- Start containers in the background:
docker-compose up -d - Start containers on the foreground:
docker-compose up. You will see a stream of logs for every container running. ctrl+c stops containers. - Stop containers:
docker-compose stop - Kill containers:
docker-compose kill - View container logs:
docker-compose logsfor all containers ordocker-compose logs SERVICE_NAMEfor the logs of all containers inSERVICE_NAME. - Execute command inside of container:
docker-compose exec SERVICE_NAME COMMANDwhereCOMMANDis whatever you want to run. Examples:- Shell into the PHP container,
docker-compose exec php-fpm bash - Run symfony console,
docker-compose exec php-fpm bin/console - Open a mysql shell,
docker-compose exec mysql mysql -uroot -pCHOSEN_ROOT_PASSWORD
- Shell into the PHP container,