Mat*_*ica 8 php docker dockerfile docker-compose
我目前正在为一个项目学习 Docker,并在我打算更改的 PHP 网站上启动了一个配置。问题是,即使我在 Dockerfile 中设置不同的版本,我也会得到相同的 PHP 版本。
这是我执行docker-compose up命令时的输出。
它继续使用 PHP 版本 7.0.33。这也是它在浏览器中显示的版本。
这是我的 docker-compose.yml 文件:
# tell docker what version of the docker-compose.yml were using
version: '3'
# define the network
networks:
web-network:
# start the services section
services:
# define the name of our service
# corresponds to the "--name" parameter
docker-php-cli:
# define the directory where the build should happened,
# i.e. where the Dockerfile of the service is located
# all paths are relative to the location of docker-compose.yml
build:
context: ./php-apache
# reserve a tty - otherwise the container shuts down immediately
# corresponds to the "-i" flag
tty: true
# mount the app directory of the host to /var/www in the container
# corresponds to the "-v" option
volumes:
- ./app:/var/www
# connect to the network
# corresponds to the "--network" option
networks:
- web-network
docker-nginx:
build:
context: ./nginx
# defines the port mapping
# corresponds to the "-p" flag
ports:
- "8080:80"
tty: true
volumes:
- ./app:/var/www
- ./nginx/conf.d:/etc/nginx/conf.d
networks:
- web-network
docker-php-fpm:
build:
context: ./php-fpm
tty: true
volumes:
- ./app:/var/www
networks:
- web-network
Run Code Online (Sandbox Code Playgroud)
这些是 Docker 文件: php-apache 文件夹
FROM php:5.6-apache
RUN pecl install xdebug-2.6.0 \
&& docker-php-ext-enable xdebug
Run Code Online (Sandbox Code Playgroud)
php-fpm 文件夹
FROM php:5.6-fpm
RUN pecl install xdebug-2.6.0 \
&& docker-php-ext-enable xdebug
Run Code Online (Sandbox Code Playgroud)
我想将其更改为 PHP 5.6,但我做不到,然后我用许多其他版本进行了测试,但它不起作用。
我确实尝试从每个 Dockerfile 中删除 RUN 部分。
有人可以帮我吗?
谢谢你!
Alu*_*tha 20
您正在使用docker-compose up该命令的作用是,它从以前构建的图像中启动容器(以查看本地使用的图像docker image ls)
更改 Dockerfile 后,您需要做的是docker-compose down
使用 --build 标志再次运行并启动。docker-compose up --build
| 归档时间: |
|
| 查看次数: |
12653 次 |
| 最近记录: |