I am trying to install Xdebug or Redis package in a Docker container from pecl. Installation failed and returns an error:
There are no releases available for package "pecl.php.net/xdebug".
Example for Xdebug: https://pecl.php.net/package/xdebug/3.1.0
My docker-compose.yaml
version: '3'
networks:
app-network:
services:
site:
build:
context: .
dockerfile: nginx.dockerfile
container_name: my_nginx
ports:
- "8082:80"
- "443:443"
volumes:
- ./src:/var/www/html
depends_on:
- php
- db
- redis
networks:
- app-network
db:
image: percona
container_name: my_db
restart: on-failure
tty: true
ports:
- "3314:3306"
volumes:
- ./percona:/var/lib/percona
environment:
MYSQL_DATABASE: mydb
MYSQL_USER: me
MYSQL_PASSWORD: 123
MYSQL_ROOT_PASSWORD: 456
SERVICE_TAGS: dev
SERVICE_NAME: db
networks:
- app-network
php:
build:
context: .
dockerfile: php.dockerfile
container_name: my_php
volumes:
- ./src:/var/www/html
ports:
- "9000:9000"
networks:
- app-network
composer:
image: frojd/composer-php-7.4
container_name: my_composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
networks:
- app-network
redis:
image: redis:alpine
container_name: my_redis
volumes:
- ./redis:/data
restart: on-failure
command: redis-server --appendonly yes --requirepass "${REDIS_PASSWORD}"
ports:
- 6380:6379
networks:
- app-network
npm:
image: node:14.18.0
container_name: my_npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ['npm']
artisan:
build:
context: .
dockerfile: php.dockerfile
container_name: my_artisan
volumes:
- ./src:/var/www/html
depends_on:
- db
working_dir: /var/www/html
entrypoint: ['php', '/var/www/html/artisan']
networks:
- app-network
cron:
build:
context: .
dockerfile: cron.dockerfile
container_name: my_cron
volumes:
- ./src:/var/www/html
networks:
- app-network
My php.dockerfile
FROM php:7.4-fpm
WORKDIR /var/www/html
RUN apt-get update && \
apt-get install ca-certificates && \
apt-get clean
RUN docker-php-ext-install pdo pdo_mysql
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
What is the cause of the error and how can I fix it?
You may be behind a proxy... I resolved this same problem by setting the proxy for PECL specifically (the environment variable alone $HTTP_PROXY won't work).
RUN pear config-set http_proxy ${http_proxy} &&\
pear config-set php_ini $PHP_INI_DIR/php.ini
RUN pecl install xdebug-3.1.1 && docker-php-ext-enable xdebug
This answer helped me: https://stackoverflow.com/a/11195778/256762. Hope mine's help as well 😉.
Related
I have an existing CakePHP project and I want to run it with Docker,
I used the command docker compose up -d and I got those containers:
Containers List in Docker
Now Obviously, it should be work on localhost:9000 and the phpmyadmin on localhost:8083.
But only the PMA (phpmyadmin) worked, and that what I got in my browser for localhost:9000
Browser Response
So this what I am facing.
DockerFile
FROM phpdockerio/php74-fpm:latest
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.4-mysql php7.4-intl php7.4-mbstring php7.4-sqlite3\
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
WORKDIR "/var/www/html"
docker-compose.yml
version: "3.8"
services:
nginx-proxy:
image: nginx
volumes:
- ./website:/var/www/html
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./docker/log:/var/log/nginx
- ./docker/certs:/etc/nginx/certs
- ./docker/nginx:/etc/nginx/conf.d
ports:
- 80:80
- 443:443
depends_on:
- php
- db
php:
build: ./docker/php/
image: php:fpm
ports:
- 9000:9000
container_name: talkto_php
environment:
- VIRTUAL_HOST=talkto_php.local
depends_on:
- db
volumes:
- ./website:/var/www/html
- ./docker/apache/apache2.conf:/etc/apache2/apache2.conf
db:
image: mysql:5.6.51
container_name: talkto_db
environment:
MYSQL_ROOT_PASSWORD: calltode
MYSQL_USER: talkto
MYSQL_PASSWORD: talkto
MYSQL_DATABASE: talkto
ports:
- "3306:3306"
volumes:
- talkto-data:/var/lib/mysql
- ./database/calltode_dev2.sql:/home/db.sql
pma:
image: phpmyadmin/phpmyadmin
container_name: pma
environment:
PMA_HOST: db
PMA_PORT: 3306
PMA_ARBITRARY: 1
restart: always
ports:
- 8083:80
links:
- db
volumes:
talkto-data:
It suppose to show me the contain of my CakePHP application on localhost:9000
I have a laravel application on a docker container
In my local windows development environment it works correctly. When I take the docker container to the ubuntu linux test server the index.php return 404 response code when i run docker compose up command in ubuntu terminal
docker_compose.yml
version: "3.9"
services:
#Nginx Service
webserver:
image: nginx:1.21.6-alpine
container_name: webserver-maderas
restart: unless-stopped
tty: true
ports:
- "8082:80"
- "444:443"
volumes:
- ./src:/var/www/
configs:
- source: nginx_config
target: /etc/nginx/conf.d/default.conf
networks:
- app-network
node:
image: node:16-alpine
working_dir: /var/www
container_name: node-maderas
volumes:
- ./src:/var/www
- /var/www/node_modules
configs:
- source: node_script
target: /var/www/node_start.sh
command: sh /var/www/node_start.sh
depends_on:
- app
networks:
- app-network
db:
image: mariadb:10.7.3-focal
container_name: db-maderas
restart: unless-stopped
tty: true
ports:
- "3308:3306"
environment:
MARIADB_DATABASE: ${MARIADB_DATABASE}
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
volumes:
- dbdata:/var/lib/mysql/
networks:
- app-network
# adminer:
# image: adminer
# restart: always
# ports:
# - 8080:8080
# networks:
# - app-network
app:
build:
context: .
dockerfile: Dockerfile
image: php:8.1-fpm-alpine3.14
container_name: app-maderas
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./src:/var/www/
networks:
- app-network
networks:
app-network:
name: network.local
driver: bridge
configs:
nginx_config:
file: ./nginx/conf.d/default.conf
node_script:
file: ./node/node_start.sh
volumes:
dbdata:
driver: local
Dockerfile
FROM php:8.1-fpm-alpine
WORKDIR /var/www/public
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
freetype-dev \
libjpeg-turbo-dev \
libmcrypt-dev \
libpng-dev
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install mysqli pdo pdo_mysql gd
RUN docker-php-ext-enable pdo_mysql
RUN addgroup -g 1000 -S www && adduser -u 1000 -S www -G www
COPY --chown=www:www ./src/ /var/www
USER www
EXPOSE 9000
CMD ["php-fpm"]
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
There is problem with Docker when using supervisor . Actually server doesn't give any error . When starting supervisor emerges problems which when enter site giving 502 errors !
When uncomment follow code in image php giving error
#ENTRYPOINT ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
Follow docker.yml
services:
webapp:
build:
context: .
dockerfile: Docker/php/prod.Dockerfile
image: webapp:php
container_name: webapp
restart: always
tty: true
stdin_open: true
volumes:
- ./Docker/php/ini/volume_conf.prod.conf:/usr/local/etc/php/conf.d/volume_conf.prod.conf
- ./Docker/php/supervisor/supervisord.conf:/etc/supervisor/supervisord.conf
- ./Docker/php/supervisor/multiProductRunner.conf:/etc/supervisor/conf.d/multiProductRunner.conf
- ./Docker/php/supervisor/crawlingProductsRunner.conf:/etc/supervisor/conf.d/crawlingProductsRunner.conf
#- ./Docker/php/supervisor/start-container:/usr/local/bin/start-container
- ./source/:/var/www/html
networks:
customnetwork:
ipv4_address: 172.20.0.10
db:
build:
context: .
dockerfile: ./Docker/mysql/Dockerfile
image: mariadb
container_name: db
restart: always
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: ''
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'password'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- ./Docker/mysql/volume/:/var/lib/mysql
networks:
customnetwork:
ipv4_address: 172.20.0.11
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-p password" ]
retries: 3
timeout: 5s
nginx:
image: nginx:alpine
container_name: nginx
tty: true
volumes:
- ./source/:/var/www/html
- ./Docker/nginx/:/etc/nginx/conf.d/
ports:
- "9001:80"
networks:
customnetwork:
ipv4_address: 172.20.0.12
meilisearch:
image: 'getmeili/meilisearch:latest'
ports:
- '7700:7700'
volumes:
- './Docker/meilisearch/volume/:/meili_data'
networks:
customnetwork:
ipv4_address: 172.20.0.13
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--spider", "5"]
retries: 3
timeout: 5s
networks:
customnetwork:
ipam:
config:
- subnet: 172.20.0.0/16
PHP version 8.1 image file (problem is there
FROM php:8.1-fpm
# PHP extensions
RUN apt-get update
RUN apt-get install -y build-essential libssl-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql gd
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
RUN echo 'memory_limit = -1' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini
RUN apt-get remove supervisor --yes
RUN apt-get install supervisor --yes
RUN service supervisor start
#COPY ./Docker/php/supervisor/multiProductRunner.conf /etc/supervisor/conf.d/supervisord.conf
#COPY ./Docker/php/supervisor/start-container /usr/local/bin/start-container
#RUN chmod +x /usr/local/bin/start-container
# when uncomment follow code giving error
#ENTRYPOINT ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
#EXPOSE 9000
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