I am currently learning Docker for a project and got a configuration to start on my PHP website that I intend to change. The problem is that even when I set up different versions in Dockerfile I get the same PHP version.
This is the output when I do the docker-compose up command.
It keeps using the PHP version 7.0.33. That’s the version that it shows in the browser as well.
This is my docker-compose.yml file:
# 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
These are the Docker files: php-apache folder
FROM php:5.6-apache
RUN pecl install xdebug-2.6.0
&& docker-php-ext-enable xdebug
php-fpm folder
FROM php:5.6-fpm
RUN pecl install xdebug-2.6.0
&& docker-php-ext-enable xdebug
I would like to change it for PHP 5.6 but I couldn’t, then I tested with many other versions and it didn’t work.
I did try removing the RUN part from each Dockerfile.
Can someone help me with that?
Thank you!
Advertisement
Answer
You are using docker-compose up
what that command does is, it’s start containers from previously build images(to see images on you local use docker image ls
)
after changing Dockerfile what you need to do is run docker-compose down
and up again with –build flag. docker-compose up --build
Relevant document https://docs.docker.com/compose/reference/up/