Forgive me if this is an obvious question. I am fairly new to docker and I am having trouble understanding the installation instructions here:
https://hub.docker.com/_/composer/
I want to use PHP Composer in my Limesurvey docker image that was generated with the following docker-compose "yml" file:
limesurvey-md:
image: mariadb
restart: always
ports:
- "32805:3306"
environment:
MYSQL_DATABASE: limesurvey
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: limesurvey
MYSQL_PASSWORD: password
volumes:
- limesurvey-db:/var/lib/mysql
- limesurvey-dblog:/var/log/mysql
- limesurvey-dbetc:/etc/mysql
limesurvey:
image: fjudith/limesurvey
restart: always
ports:
- "32705:80"
volumes:
- limesurvey-upload:/var/www/html/upload
links:
- limesurvey-md:mysql
What do I need to add to my yml file to accomplish this? If it helps, there is a directory called "application" in the Limesurvey image:
/var/www/html/application
And how do I give this composer a command while it is in the container? I am using Windows 10 and the docker container is running the default linux environment. fjudith's Limesurvey container is using the last 2.X branch of Limesurvey (the one right before 3.X) and it is running PHP 7.2
You can create a custom image with a dockerfile build, yo can specify the dockerfile name in the build section, the docker-compose.yml and dockerfile are in the same folder here i attach and example:
docker-compose.yml:
version: '3.1'
services:
limesurvey-md:
image: mariadb
restart: always
ports:
- 32805:3306
environment:
MYSQL_DATABASE: limesurvey
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: limesurvey
MYSQL_PASSWORD: password
volumes:
- limesurvey-db:/var/lib/mysql
- limesurvey-dblog:/var/log/mysql
- limesurvey-dbetc:/etc/mysql
limesurvey:
build:
context: .
dockerfile: dockerfile
restart: always
ports:
- 32705:80
volumes:
- limesurvey-upload:/var/www/html/upload
links:
- limesurvey-md:mysql
volumes:
limesurvey-db:
driver: local
limesurvey-dblog:
driver: local
limesurvey-dbetc:
driver: local
limesurvey-upload:
driver: local
dockerfile:
FROM "fjudith/limesurvey:latest"
LABEL maintainer="ing.brayan.cm#gmail.com"
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Thanks Brayan! I just (10 minutes ago) figured out another way, you can also do a bash command. Since I was in Windows the two lines I had to do in my command prompt were
docker exec -it <my_container_name> bash
Then it put me into "/var/www/html#" where I did the following command:
$sudo curl -o /tmp/composer-setup.php https://getcomposer.org/installer && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot && rm -f /tmp/composer-setup.*
I adapted the second line from here: Get composer (php dependency manager) to run on a docker image build
From there it's easy! You can just do
composer
and it guides you through the possible commands. It suggests not using the "root" administrator. I'll have to look into creating another user in the docker image.
Related
I am working with an docker image nanoninja/php-fpm:8.1.
When I run the image manually, the PHP works.
docker container run --rm --name phpfpm -v $(pwd):/var/www/html -p 3000:3000 nanoninja/php-fpm php -S="0.0.0.0:3000" -t="/var/www/html"
But when I try to run the same image with docker-compose.yml file, I don't get a connection to PHP.
Here is my very simple docker-compose.yml file:
version: '3'
services:
php:
image: nanoninja/php-fpm:8.1
restart: always
ports:
- 3000:9000
stdin_open: true
tty: true
I'm not using a Dockerfile.
Question: How to run PHP without Nginx using only docker-compose.yml file?
Image link: https://github.com/nanoninja/php-fpm
The docker-compose file equivalent to your docker container run command would be something like
version: "3"
services:
php:
image: nanoninja/php-fpm:8.1
container_name: phpfpm
restart: always
ports:
- 3000:3000
command: php -S="0.0.0.0:3000" -t="/var/www/html"
volumes:
- ./:/var/www/html
The -v option becomes the volumes: section. The part after the image name becomes the command:. The -p option becomes the ports: section. --name becomes container_name:, etc.
I'm working on a project in Laravel and using Docker. I don't know why I suddenly get this error message from PhpStorm.
I ran sudo chmod 777 -R my-project-name but I keep getting the error message.
How can I fix that?
The error message:
Docker file:
FROM php:8.1-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /app
COPY . .
RUN composer install
CMD php artisan serve --host=0.0.0.0
docker-compose.yml file:
version: '3.8'
services:
backend:
build:
context: .
dockerfile: Dockerfile
ports:
- 8000:8000
volumes:
- .:/app
depends_on:
- db
db:
image: mysql:5.7.22
restart: unless-stopped
ports:
- 33066:3306
environment:
MYSQL_DATABASE: admin
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
volumes:
- ./mysql:/var/lib/mysql
When you run docker-compose
It will creat a project with ower is root or name for docker set. You will see lock icon in the folder. Current, you are only a visitor. But you always change files that you are not owner. How can do it?
When start you can run.
sudo chmod 777 -R my-project-name
But it is not good. Because everyone can change your file without permission.
Solution:
check permission your file:
getfacl [relate_path_your_file]/TestController.php or ls -l [relate_path_your_file]/TestController.php
[enter image description here][1]
[1]: https://i.stack.imgur.com/9T85A.png
Add your account to group of this project
sudo adduser {USER-NAME-HERE} {GROUP-NAME-HERE}
Add write permission for group user
sudo chmod g+w [relate_path_your_file]/TestController.php
Right now your group user can edit file, include you
If you want to change others file, redo step 3 with path your file.
If not work, reopen phpStom
I am using the Docker Engine running on WSL2 which is running on Windows 10 computer. My goal is to create a service using the Docker-compose that uses the php:fpm image and install the mysqli extension to it. Here is my docker-compose.yaml
version: "3"
services:
nginx:
image: "nginx"
restart: 'always'
ports:
- '3030:80'
volumes:
- ./src:/src
- ./config/site.conf:/etc/nginx/conf.d/default.conf
networks:
- code-network
php:
build:
context: .
dockerfile: Dockerfile
image: php:fpm
volumes:
- ./src:/src
networks:
- code-network
mariadb:
image: "mariadb:10.3.24"
restart: 'always'
volumes:
- "/var/lib/mysql/data:/data"
- "/var/lib/mysql/logs:/logs"
- /var/docker/mariadb/conf:/etc/mysql
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "T05CNCitk2020#"
MYSQL_USER: "user"
MYSQL_PASSWORD: "Heslo123"
networks:
- code-network
networks:
code-network:
driver: bridge
And here is my Dockerfile:
FROM php:fpm
RUN docker-php-ext-install mysqli
When I run the command docker-compose up --build which forces the container to rebuild. I ran into the following problem:
Building php
unable to prepare context: path "\\\\?\\\\\\wsl$\\Ubuntu-20.04\\home\\vendasky\\Projects\\sql-gui" not found
ERROR: Service 'php' failed to build : Build failed
I do not see the reason why the path should be wrong when all the files are located in the Linux subsystem. Any hints, how to solve this problem?
are you runnning this with docker desktop for windows?
If thats the case try enabling the Docker Compose V2 option under the experimental settings. This should fix your problem.
Docker is unable to find the path to that project, map your ubuntu correctly so it can easily locate the project, that should fix your issue.
I am using docker for my app that includes freeradius,nginx and php.
I want to use "program = "/usr/bin/php " this command in container freeradius but it is not working.
In freeradius container I want to run this command "/usr/bin/php" but it says command not found.
Can anyone help me in this ?
version: '3.2'
services:
freeradius:
image: "ronakzenexim/2stacks_freeradius:v1"
environment:
- RAD_DEBUG=yes
depends_on:
- mysql
- php
links:
- mysql
restart: always
networks:
- backend
php:
image: "ronakzenexim/phpfpm72_mycrypt"
restart: always
volumes:
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- "./web:/var/www/html"
networks:
- backend
networks:
backend:
ipam:
config:
- subnet: 10.0.0.0/24
Create a extension of the freeradius docker image for example
FROM ronakzenexim/2stacks_freeradius:v1
# Now install php
RUN apk update && apk upgrade
RUN apk add php7 php7-fpm php7-opcache
In this container you can run php.
I run a WordPress installation in a docker-container with the WordPress image (https://hub.docker.com/_/wordpress/). My problem is that I can't send mails via wp_mail() or with PHP mail().
When I try to call a mail()-function I get an "Internal Server Error".
What can I do? Do I need a external mail server?
My docker-compose.yml:
wordpress:
image: wordpress
container_name: shk_wordpress
links:
- mariadb:mysql
environment:
- WORDPRESS_DB_PASSWORD=admin
ports:
- "8000:80"
volumes:
- ./app:/var/www/html
- ./theme/:/var/www/html/wp-content/themes/shk-theme
mariadb:
image: mariadb
container_name: shk_mariadb
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_DATABASE=wordpress
volumes:
- ./database:/var/lib/mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: shk_phpmyadmin
environment:
- PMA_ARBITRARY=1
- MYSQL_USER=root
- MYSQL_PASSWORD=admin
- MYSQL_ROOT_PASSWORD=admin
ports:
- "9000:80"
links:
- "mariadb:mysql"
It seems that this problem was already been discused at WP docker image repo.
Checkout this answer on
Github
Further down you might find some other solutions to your problem if that one doesn't work.
Step 1 :
In your docker-compose.yml, replace
image: wordpress
by
build: .
Step 2 :
Create a Dockerfile :
FROM wordpress
RUN apt-get update
RUN apt-get install -y ssmtp
RUN echo "sendmail_path = /usr/sbin/ssmtp -t" >> /usr/local/etc/php/conf.d/sendmail.ini
RUN sed -i -e 's/mailhub=mail/mailhub=[IP RELAY SERVER]/' /etc/ssmtp/ssmtp.conf
RUN sed -i -e 's/#rewriteDomain=/rewriteDomain=[IP RELAY SERVER]/' /etc/ssmtp/ssmtp.conf
RUN sed -i -e '/hostname=/d' /etc/ssmtp/ssmtp.conf
Step 3 :
Replace [IP RELAY SERVER]