The behavior of a docker container

Hello,
I have created a PHP container as follows:

version: '3.9'
services:
  php-fpm:
    image: php:8-fpm
    volumes:
      - /var/www/html:/var/www/html

Now I have created another container as follows:

version: '3.9'
services:
  web:
    image: nginx:latest
    ports:
      - '80:80'
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf
      - /var/www/html:/usr/share/nginx/html
    links:
      - php-fpm
  php-fpm:
    image: php:8-fpm

Will the PHP container be downloaded again for this new container?

Cheers.

1 Like

I don’t really understand your question…

In your example, you’re given two yaml files… Here, you just can have one by putting the first “content” to the second file i.e. declare the two services in the same file.

By running docker composer up, the yaml file will be processed, the services will be build if needed and containers will be created.

Is this an answer to your question ?

Hi,
Thank you so much for your reply.
Not really. As you can see, I have two different YAML files, each located in a different directory. I have used php-fpm in both containers. I want to know that for the second container, will php-fpm be downloaded again?

If you mean downloaded from Internet no.

The container php-fpm will be used. If not yet started, the container will be first started but, no, no more download.

1 Like