I'm trying install laravel package via composer in WSL 2 docker with sail laravel CLI, but composer not install package, why?
Error screenshot
docker file
# For more information: https://laravel.com/docs/sail
version: '3.8'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
mysql:
image: 'mysql:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_HOST: '${DB_HOST}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'sailmysql:/var/lib/mysql'
networks:
- sail
phpmyadmin:
image: 'phpmyadmin'
container_name: pma
environment:
PMA_HOST: '${DB_HOST}'
PMA_PASSWORD: '${DB_PASSWORD}'
PMA_ARBITRARY: 1
restart: always
ports:
- 8081:80
depends_on:
- mysql
networks:
- sail
networks:
sail:
driver: bridge
volumes:
sailmysql:
driver: local
sailredis:
driver: local
information
windows version 10 build 19042
debian wls 2
docker 20.10.2, build 2291f61
laravel 8
composer integrated with laravel 2.0.8
how do I solve this?
I solved that. Deleted folder vendor, and run composer install, that worked.
thank so much childs
I had the same problem as well, but when I fixed the file permissions, it was fixed.
https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/
Related
I am using the following docker-compose.yaml file:
version: "3.9"
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./src:/var/www/html
- ./default.conf:/etc/nginx/conf.d/default.conf
links:
- php-fpm
php-fpm:
image: php:8-fpm
volumes:
- ./src:/var/www/html
db:
image: 'jc21/mariadb-aria:latest'
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: 'secretpassword.'
MYSQL_DATABASE: 'secretdb'
MYSQL_USER: 'secretuser'
MYSQL_PASSWORD: 'secretpassword.'
volumes:
- ./data/mysql:/var/lib/mysql
phpmyadmin:
image: lscr.io/linuxserver/phpmyadmin:latest
container_name: pma
links:
- db
environment:
PMA_ARBITRARY: 0
PMA_HOST: db
PMA_PORT: 3306
restart: always
ports:
- 8085:80
It works fine. I wanna test a cms. I need the GD library. But it seems that it is not installed yet.
How can I install the GD library?
I went into the php-fpm container. I installed the gd library successfully! Thanks for the tip!
I am creating an image for a php8 project run on apache, and work with phpMyAdmin, I have my Dockerfile as follow :
FROM php:8.0-apache
RUN apt-get update -y && apt-get install -y libmariadb-dev && docker-php-ext-install mysqli && docker-php-ext-install pdo_mysql
WORKDIR /var/www/html
And my docker-compose.yml as follow :
services:
php-apache-environment:
container_name: php-apache
image: php:8.0-apache
volumes:
- ./php/src:/var/www/html/
ports:
- 8000:80
db:
container_name: db
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: MY_DATABASE
MYSQL_USER: MYSQL_USER
MYSQL_PASSWORD: MYSQL_PASSWORD
ports:
- "9906:3306"
phpmyadmin:
image: phpmyadmin:latest
ports:
- '8080:80'
restart: always
environment:
PMA_HOST: db
depends_on:
- db
For me, all is good, but when I run "docker compose up --build", container is launched, but he has not install "mysqli" and "pdo_mysql" like I request in the Dockerfile.
But, if I log in by CLI to the PHP container, and that I run docker-php-ext-install mysqli and docker-php-ext-install pdo_mysql, it works, and I just have to restart the PHP container.
But, I dont know why, I can't install it from the start ?
Thank you for your help.
Thans to Lety comment, we juste need to change the line 4 of docker-compose.yml
by :
build: ./php
(to indicate the directory where the Dockerfile is) and it works.
Resume :
Dont change the Dockerfile
. Change the docker-compose.yml by :
version: '3.8'
services:
php-apache-environment:
container_name: php-apache
build: ./php
volumes:
- ./php/src:/var/www/html/
ports:
- 8000:80
db:
container_name: db
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: MY_DATABASE
MYSQL_USER: MYSQL_USER
MYSQL_PASSWORD: MYSQL_PASSWORD
ports:
- "9906:3306"
phpmyadmin:
image: phpmyadmin:latest
ports:
- '8080:80'
restart: always
environment:
PMA_HOST: db
depends_on:
- db
I have a php project with docker
The docker-compose file is as shown below
version: "3.1"
services:
php:
image: php:5.3-apache
restart: always
ports:
- 5030:80
volumes:
- ./:/var/www/html
# - /home/asish/Work/CodePoint/php/php.ini:/usr/local/lib/php.ini
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
- "5001:3306"
environment:
MYSQL_ROOT_PASSWORD: password
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8000:80
environment:
- PMA_ARBITRARY=1
- UPLOAD_LIMIT=300000000
I need to install openssl extension and activate it. I tried mapping a php.ini file with openssl extension enabled but it is not enabled in the server.
How to install and activate the openssl extension in this case
I've the following docker-compose file, and need some help with PHP composer part commented below:
version: '3'
services:
proxy:
image: jwilder/nginx-proxy
container_name: proxy
ports:
- '80:80'
- '443:443'
volumes:
- './certs:/etc/nginx/certs'
- '/var/run/docker.sock:/tmp/docker.sock:ro'
restart: always
web:
image: 'nginx:latest'
container_name: nginx
volumes:
- './volume1:/volume1'
- './volume2:/volume2'
- './volume3:/volume3'
- './site.conf:/etc/nginx/conf.d/site.conf'
environment:
- 'VIRTUAL_HOST=host1.local,host2.local,host3.local'
restart: always
php:
build: .
container_name: php
volumes:
- './volume1:/volume1'
- './volume2:/volume2'
- './volume3:/volume3'
restart: always
# Start How TODO this?
composer:
image: 'composer:latest'
container_name: composer
command: install
volumes:
- './volume1:/app'
- './volume2:/app'
- './volume3:/app'
# End HOW TODO this?
db:
image: mariadb
container_name: mariadb
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=toor
volumes:
- './db:/var/lib/mysql'
restart: always
pma:
image: phpmyadmin/phpmyadmin
container_name: pma
environment:
- PMA_ARBITRARY=1
- 'PMA_ABSOLUTE_URI=https://pma.local/'
- VIRTUAL_HOST=pma.local
restart: always
I've multiple app that needs to use composer, but I can't overwrite /app folder inside the composer container. Should I write a Dockerfile inside each single app folder? I don't want to specify the full path of PHP app inside the docker-compose, because I can have multiple version of an app (like 1.0, 2.0, ecc.ecc.).
Instead of putting the Composer configuration in your Docker Compose file, you should probably just run it once for each PHP app before you run the system.
docker run --rm -v $(pwd)/volume1:/app composer:latest install
This will run composer and bind the directory to your host filesystem so that the vendor folder will be available.
In linux I build a blog application that is based on mysql, apache2 and php. But I use some python for it. The python is for adapting python Pygments that is described there https://davidwalsh.name/pygments-php-wordpress .
I prepared docker compose stage that works fine but python does not work in it. How to add python to docker compose?
Here are my files:
root#debian:/usr/local/share/a22php7m55# cat docker-compose.yml
version: "2.1"
services:
apachephp:
build: ./a22php7/
ports:
- 8888:80
volumes:
- "/etc/passwd:/etc/passwd:ro"
- "/etc/group:/etc/group:ro"
- "${PROJECT_ROOT}:/var/www/html"
networks:
- database
- server
depends_on:
- mysql
container_name: ap47
mysql:
image: mariadb:5.5
volumes:
- ${MYSQL_DATA}:/var/lib/mysql
networks:
- database
environment:
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
MYSQL_DATABASE: "${MYSQL_NAME}"
MYSQL_USER: "${MYSQL_USERNAME}"
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
container_name: maria47
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8080:80
networks:
- database
depends_on:
- mysql
environment:
PMA_HOST: mysql
container_name: pma47
volumes:
mariadb:
networks:
database:
server:
root#debian:/usr/local/share/a22php7m55# cat a22php7/
root#debian:/usr/local/share/a22php7m55# cat a22php7/Dockerfile
FROM php:7.1.3-apache
RUN docker-php-ext-install pdo pdo_mysql
root#debian:/usr/local/share/a22php7m55#
Looking at the base image for php:7.1.3-apache we see it's built on debian:jessie so we can install python, pip and pygments by adding these lines to your Dockerfile:
RUN apt-get update && apt-get install -y python python-pip
RUN pip install pygments