Override image version in docker-compose file

I'm working on a redefinition of the file docker-compose.ymlby default docker-compose.override.yml, as shown in this link , and I can point to portsand volumesin the overriding file.

Similarly, is it also possible to specify the version of the image to be deployed? If not, what is the best way to handle such circumstances when we need to specify a different version for the image?

Any help on this would be great.

+4
source share
2 answers

Docker already has this feature. I tried to override the image name with a simple docker-compose command, it works.

For instance,

docker-compose.yml with content

my-httpd:
  image: httpd:latest
  ports:
    - "1110:80"  

docker-compose.override.yml ,

my-httpd:
  image: httpd:2.4

docker-compose -d docker ps,

enter image description here

ports docker-compose.yml ( ) image docker-compose.override.yml, .

. , docker-compose -d,

docker-compose -f <DOCKER COMPOSE LOCATION> -f <OVERRIDE FILE LOCATION> up -d

2:

, .

, ports , , , image (non array).

+6

, 3 :

  • --master.yml

  • --dev.yml

  • --docker.yml

3 -- .

enter image description here

-3

All Articles