Docker总是加载我在Dockerfile中设置的错误PHP版本

Docker总是加载我在Dockerfile中设置的错误PHP版本,php,docker,docker-compose,dockerfile,Php,Docker,Docker Compose,Dockerfile,我目前正在为一个项目学习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' #

我目前正在为一个项目学习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
以下是Docker文件: php apache文件夹

FROM php:5.6-apache
RUN pecl install xdebug-2.6.0 \
    && docker-php-ext-enable xdebug
php fpm文件夹

FROM php:5.6-fpm
RUN pecl install xdebug-2.6.0 \
    && docker-php-ext-enable xdebug
我想把它改成PHP5.6,但我做不到,然后我用许多其他版本进行了测试,结果都不起作用

我确实尝试从每个Dockerfile中删除运行部分

有人能帮我吗


谢谢大家!

您使用的是
docker compose up
该命令的作用是,从以前生成的图像启动容器(要查看本地图像,请使用
docker image ls

更改Dockerfile后,您需要做的是运行
docker compose down
然后再次使用--build标志<代码>docker组装--构建

相关文件


您正在使用
docker compose up
该命令所做的是,它从以前生成的图像启动容器(要查看本地图像,请使用
docker image ls

更改Dockerfile后,您需要做的是运行
docker compose down
然后再次使用--build标志<代码>docker组装--构建

相关文件


您是否在
up
之前执行了
docker compose build
?您可以使用:
docker compose up--build
强制执行up命令中的构建您是否在
up
之前执行了
docker compose build
强制执行up命令中的构建?您可以使用:
docker compose--build
强制执行up命令中的构建谢谢,我注意到,在前面的评论中,=)现在它可以工作了,只需要安装mysql。谢谢,我注意到在前面的评论中。=)现在,它正在工作,将只是设置mysql。