我正在尝试从我的php应用程序中使用AWS RDS postgresql。我已经将Dockerfile修改为包含 运行apt-get更新&& apt-get安装-y libpq-dev && docker-php-ext-install pdo pdo_pgsql 但是它似乎没有运行。我认为这是因为,当我(最终)从容器中运行phpinfo()时,我看不到它已加载。我假设当我运行docker-compose up时,Dockerfile(构建php-fpm)是“自动”运行的。真的吗?这是似乎未运行的Dockerfile:
FROM bitnami/php-fpm:7.2 as builder
RUN install_packages git autoconf build-essential
WORKDIR /app
RUN wget https://github.com/xdebug/xdebug/archive/2.6.0.tar.gz && \
tar xzf 2.6.0.tar.gz && \
cd xdebug-2.6.0 && \
phpize && \
./configure --enable-xdebug && \
make && make install
RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql
FROM bitnami/php-fpm:7.2
COPY --from=builder /opt/bitnami/php/lib/php/extensions/xdebug.so /opt/bitnami/php/lib/php/extensions/
RUN echo 'zend_extension="/opt/bitnami/php/lib/php/extensions/xdebug.so"' >> /opt/bitnami/php/etc/php.ini
RUN echo "xdebug.remote_port=9000" >> /opt/bitnami/php/etc/php.ini \
&& echo "xdebug.remote_enable=1" >> /opt/bitnami/php/etc/php.ini \
&& echo "xdebug.remote_connect_back=0" >> /opt/bitnami/php/etc/php.ini \
&& echo "xdebug.remote_host=192.168.122.1" >> /opt/bitnami/php/etc/php.ini \
&& echo "xdebug.idekey=docker" >> /opt/bitnami/php/etc/php.ini \
&& echo "xdebug.remote_autostart=1" >> /opt/bitnami/php/etc/php.ini \
&& echo "xdebug.remote_log=/tmp/xdebug.log" >> /opt/bitnami/php/etc/php.ini \
&& echo "extension=pgp_pdo_pgsql.so" >> /opt/bitnami/php/etc/php.ini \
&& echo "extension=pgp_pgsql.so" >> /opt/bitnami/php/etc/php.ini
这是docker-compose
version: '3'
services:
apache:
image: bitnami/apache:latest
restart: unless-stopped
ports:
- 80:8080
volumes:
- ./apache/app.conf:/vhosts/app.conf:ro
- ./app:/app
networks:
- net
mysql:
container_name: "mysql"
restart: unless-stopped
image: mysql:5.6
environment:
- MYSQL_DATABASE
- MYSQL_PASSWORD
- MYSQL_ROOT_PASSWORD
- MYSQL_USER
volumes:
- data:/var/lib/mysql
- ./mysql/mysql.sql:/docker-entrypoint-initdb.d/mysql.sql
ports:
- "3306:3306"
networks:
- net
phpmyadmin:
container_name: phpmyadmin
restart: unless-stopped
image: phpmyadmin/phpmyadmin
environment:
- PMA_HOST=mysql
- PMA_PORT=3306
ports:
- "8081:80"
networks:
- net
php-fpm:
build: ./php
restart: unless-stopped
image: bitnami/php-fpm
volumes:
- ./app:/app
environment:
- XDEBUG_CONFIG="remote_host=192.168.122.1"
networks:
- net
jasperreports:
image: 'bitnami/jasperreports:7'
restart: unless-stopped
environment:
- MARIADB_HOST=mysql
- MARIADB_PORT_NUMBER=3306
- JASPERREPORTS_USERNAME=admin
- JASPERREPORTS_PASSWORD=bitnami
- JASPERREPORTS_DATABASE_USER=admin
- JASPERREPORTS_DATABASE_PASSWORD=xxx
- JASPERREPORTS_DATABASE_NAME=jasper
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '8080:8080'
volumes:
- jasperreports_data:/bitnami
depends_on:
- mysql
networks:
- net
volumes:
data:
driver: local
jasperreports_data:
driver: local
如果此Dockerfile没有自动运行,如何获取它来创建新的php-fpm容器?
答案 0 :(得分:2)
如果您更改Dockerfile
,并想用docker-compose up
更新图像,则需要将标志--build
传递给docker-compose up
。
--build
在启动容器之前构建映像。
docker-compose up --build