I can’t figure out why Sail installs PHP 8.1 in stead of 8.0. It breaks my app for now.
This is the docker-compose.yml:
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
build:
context: ./docker/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
- redis
...
and this is the Docker file: https://github.com/laravel/sail/blob/1.x/runtimes/8.0/Dockerfile
I have rebuilt the image many times but I still get this:
sail@c5f380167b79:/var/www/html$ php -v
PHP 8.1.2 (cli) (built: Jan 24 2022 10:42:51) (NTS)
2
Answers
It helped adding this line: RUN update-alternatives --set php /usr/bin/php8.0
https://github.com/laravel/sail/commit/dbe4a908d254d91f99ed89047c9eec4bae8973b0
Please check the [documentation][1] that states how to set the right php version, as well as then rebuild the sail container:
Sail currently supports serving your application via PHP 8.1, PHP 8.0, or PHP 7.4. The default PHP version used by Sail is currently PHP 8.1. To change the PHP version that is used to serve your application, you should update the build definition of the laravel.test container in your application’s docker-compose.yml file:
PHP 8.1
context: ./vendor/laravel/sail/runtimes/8.1
PHP 8.0
context: ./vendor/laravel/sail/runtimes/8.0
PHP 7.4
context: ./vendor/laravel/sail/runtimes/7.4
In addition, you may wish to update your image name to reflect the version of PHP being used by your application. This option is also defined in your application’s docker-compose.yml file:
image: sail-8.1/app
After updating your application’s docker-compose.yml file, you should rebuild your container images:
sail build –no-cache
sail up
[1]: https://laravel.com/docs/9.x/sail#sail-php-versions