I am trying to get xdebug to work in a php container within a docker-compose setup. I found a few examples that show the extra config lines that need to be added to the container:
From Reddit, I have tried to add these lines in my web container's Dockerfile:
# Configure xdebug
RUN echo "xdebug.remote_enable=1" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.idekey=PHPSTORM" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.remote_connect_back=1" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.remote_host=10.10.1.2" >> /etc/php5/fpm/conf.d/20-xdebug.ini
But I am not directly using a dockerfile as far as I can tell.
my docker-compose.yml:
web:
image: tutorial/nginx
ports:
- "8080:80"
volumes:
- ./src:/var/www
- ./src/vhost.conf:/etc/nginx/sites-enabled/vhost.conf
links:
- php
php:
image: nmcteam/php56
volumes:
- ./src/php-fpm.conf:/etc/php5/fpm/php-fpm.conf
- ./src:/var/www
run:
# Configure xdebug
RUN echo "xdebug.remote_enable=1" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.idekey=PHPSTORM" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.remote_connect_back=1" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.remote_host=10.10.1.2" >> /etc/php5/fpm/conf.d/20-xdebug.ini
links:
- db
db:
image: sameersbn/mysql
volumes:
- /var/lib/mysql
environment:
- DB_NAME=demoDb
- DB_USER=demoUser
- DB_PASS=demoPass
Clearly the run: section does not work. I'm missing something, but so far have not been able to get my head around how to solve the problem using compose.
答案 0 :(得分:3)
run
不是docker-compose
您可以使用image
build
或Dockerfile
因此,您可以在RUN
中使用Dockerfile
。 Reference
我的建议是,如果你需要运行你指定的命令,你可以为你的'php'Dockerfile
执行类似的操作:
FROM nmcteam/php56
RUN echo "xdebug.remote_enable=1" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.idekey=PHPSTORM" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.remote_connect_back=1" >> /etc/php5/fpm/conf.d/20-xdebug.ini
RUN echo "xdebug.remote_host=10.10.1.2" >> /etc/php5/fpm/conf.d/20-xdebug.ini
构建图像:
docker build -t myuser/php56 <path to Dockerfle>
然后在你的docker-compose.yml
文件中,在'php'部分:
php:
image: myuser/php56
volumes:
- ./src/php-fpm.conf:/etc/php5/fpm/php-fpm.conf
- ./src:/var/www
links:
- db
您可以选择将图片推送到dockerhub帐户:
docker push myuser/php56