I start under docker and I do not understand the difference between volumes and configs.
https://docs.docker.com/compose/compose-file/#volumes-top-level-element
https://docs.docker.com/compose/compose-file/#configs-top-level-element (added in version 3.3 of docker compose)
Should the configs properties be defined if, for example, a configuration file is used on different services ?
In what case does it apply ?
For example to share the Apache Root Document (/usr/local/apache2/htdocs) with volumes :
version: '3.8'
services:
apache:
image: httpd:2.4
restart: always
ports:
- 8000:80
volumes:
- ./:/usr/local/apache2/htdocs
- php-socket:/run/php
depends_on:
- php-fpm
networks:
- code
php-fpm:
image: php:7.4-fpm
restart: always
ports:
- 9000:9000
volumes:
- ./:/usr/local/apache2/htdocs
- ./.docker/php-fpm/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf
- php-socket:/run/php
networks:
- code
volumes:
php-socket:
networks:
code:
What is the difference with the configs properties ? :
version: '3.8'
services:
apache:
image: httpd:2.4
restart: always
ports:
- 8000:80
volumes:
- php-socket:/run/php
configs:
- source: apache-www
target: /usr/local/apache2/htdocs
depends_on:
- php-fpm
networks:
- code
php-fpm:
image: php:7.4-fpm
restart: always
ports:
- 9000:9000
volumes:
- ./.docker/php-fpm/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf
- php-socket:/run/php
configs:
- source: apache-www
target: /usr/local/apache2/htdocs
networks:
- code
volumes:
php-socket:
configs:
apache-www:
file: ./
networks:
code:
The two examples above work, But I don't understand the difference between volumes and configs ?
Can anyone explain to me ? Thanks !