{"id":1128,"date":"2024-07-22T20:41:23","date_gmt":"2024-07-22T20:41:23","guid":{"rendered":"https:\/\/dockerpros.com\/?post_type=glossary&#038;p=1128"},"modified":"2024-07-22T20:55:31","modified_gmt":"2024-07-22T20:55:31","slug":"docker-compose-config","status":"publish","type":"glossary","link":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/","title":{"rendered":"Docker Compose Config"},"content":{"rendered":"<h1>Understanding Docker Compose Config: A Comprehensive Guide<\/h1>\n<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is an <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\" target=\"_blank\">orchestration<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">L'orchestration d\u00e9signe la gestion et la coordination automatis\u00e9es de syst\u00e8mes et de services complexes. Elle optimise les processus en int\u00e9grant diverses composantes, en garantissant un fonctionnement efficace et une utilisation optimale des ressources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> tool that simplifies the management of multi-container Docker applications. By defining services, networks, and volumes in a single <span class=\"glossaryai-tooltip glossary-term-690\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/yaml\/\" target=\"_blank\">YAML<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files. It emphasizes simplicity and clarity, making it suitable for both developers and non-developers.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/yaml\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> file, <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> enables developers to deploy, manage, and scale their applications with ease. The configuration file, commonly named <code>docker-compose.yml<\/code>, sert de plan qui d\u00e9crit comment les diff\u00e9rents composants d'une application interagissent, facilitant ainsi un environnement coh\u00e9rent et reproductible dans diff\u00e9rentes configurations.<\/p>\n<h2>Why Use Docker Compose?<\/h2>\n<p>The complexity of modern applications often demands the use of multiple services that need to work together. <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> addresses this complexity by allowing developers to define all components of an application, including databases, caches, and web services, in a single file. This not only simplifies the setup process but also enhances collaboration within teams, as the configuration file can be shared and version-controlled like any other code artifact.<\/p>\n<h3>Avantages principaux<\/h3>\n<ol>\n<li>\n<p><strong>Simplicit\u00e9<\/strong>: The ability to define multi-container applications in a single <span class=\"glossaryai-tooltip glossary-term-690\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/yaml\/\" target=\"_blank\">YAML<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files. It emphasizes simplicity and clarity, making it suitable for both developers and non-developers.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/yaml\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> file makes it easy to understand the architecture of an application.<\/p>\n<\/li>\n<li>\n<p><strong>Consistency<\/strong>: <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> ensures that the environment is consistent across different stages of development, testing, and production.<\/p>\n<\/li>\n<li>\n<p><strong>Isolation<\/strong>: Each <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> runs in its <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, ce qui permet une meilleure isolation et une meilleure gestion des ressources.<\/p>\n<\/li>\n<li>\n<p><strong>\u00c9volutivit\u00e9<\/strong>: Les services peuvent \u00eatre facilement mis \u00e0 l'\u00e9chelle en ajustant la configuration.<\/p>\n<\/li>\n<li>\n<p><strong>R\u00e9seautage<\/strong>: <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> automatically creates a default <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> pour que les services d\u00e9finis puissent communiquer de mani\u00e8re transparente.<\/p>\n<\/li>\n<\/ol>\n<h2>Structure d'un fichier Docker Compose\n\nA Docker Compose file is a YAML file that defines the services, networks, and volumes for a Docker application. It is used to configure and manage multi-container applications. The file typically has the following structure:\n\n```yaml\nversion: '3.8'\n\nservices:\n  service1:\n    image: image1\n    ports:\n      - \"8080:8080\"\n    environment:\n      - ENV_VAR1=value1\n      - ENV_VAR2=value2\n    volumes:\n      - .\/data:\/data\n\n  service2:\n    image: image2\n    ports:\n      - \"8081:8081\"\n    environment:\n      - ENV_VAR1=value1\n      - ENV_VAR2=value2\n    volumes:\n      - .\/data:\/data\n\nnetworks:\n  network1:\n    driver: bridge\n\nvolumes:\n  volume1:\n    driver: local\n```\n\nIn this example, the file defines two services (`service1` and `service2`), a network (`network1`), and a volume (`volume1`). Each service specifies the Docker image to use, the ports to expose, environment variables, and volumes to mount. The network and volume sections define the network and volume configurations, respectively.\n\nThe `version` field specifies the version of the Docker Compose file format. The `services` section defines the services that make up the application. Each service can have its own configuration, such as the Docker image to use, ports to expose, environment variables, and volumes to mount.\n\nThe `networks` section defines the networks that the services can connect to. Each network can have its own configuration, such as the network driver to use.\n\nThe `volumes` section defines the volumes that the services can use. Each volume can have its own configuration, such as the volume driver to use.\n\nDocker Compose files can be used to define and manage complex multi-container applications. They provide a convenient way to configure and manage the services, networks, and volumes that make up an application.<\/h2>\n<p>A <code>docker-compose.yml<\/code> Le fichier se compose de plusieurs \u00e9l\u00e9ments cl\u00e9s, chacun jouant un r\u00f4le dans la d\u00e9finition de la structure de l'application. Les composants principaux incluent :<\/p>\n<ol>\n<li>\n<p><strong>Version<\/strong>: Specifies the version of the <span class=\"glossaryai-tooltip glossary-term-689\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\" target=\"_blank\">fichier Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Un fichier Docker Compose est un fichier de configuration YAML qui d\u00e9finit les services, les r\u00e9seaux et les volumes pour les applications Docker multi-conteneurs. Il simplifie le d\u00e9ploiement et la gestion, am\u00e9liorant ainsi l'efficacit\u00e9.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> format.<\/p>\n<\/li>\n<li>\n<p><strong>Services<\/strong>: This section defines each individual <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, including its <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une image est une repr\u00e9sentation visuelle d'un objet ou d'une sc\u00e8ne, g\u00e9n\u00e9ralement compos\u00e9e de pixels dans les formats num\u00e9riques. Elle peut transmettre des informations, susciter des \u00e9motions et faciliter la communication \u00e0 travers diff\u00e9rents m\u00e9dias.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, construire le contexte, les variables d'environnement, les ports, et bien plus encore.<\/p>\n<\/li>\n<li>\n<p><strong>Les r\u00e9seaux<\/strong>: Des r\u00e9seaux personnalis\u00e9s peuvent \u00eatre d\u00e9finis pour contr\u00f4ler la mani\u00e8re dont les services communiquent entre eux.<\/p>\n<\/li>\n<li>\n<p><strong>Volumes<\/strong>: Persistent storage can be defined to retain data across <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> restarts.<\/p>\n<\/li>\n<\/ol>\n<h3>Structure de base<\/h3>\n<p>Here is a basic example to illustrate the structure of a <span class=\"glossaryai-tooltip glossary-term-689\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\" target=\"_blank\">fichier Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Un fichier Docker Compose est un fichier de configuration YAML qui d\u00e9finit les services, les r\u00e9seaux et les volumes pour les applications Docker multi-conteneurs. Il simplifie le d\u00e9ploiement et la gestion, am\u00e9liorant ainsi l'efficacit\u00e9.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-yaml\">version: '3.8'\n\nservices:\n  web:\n    image: nginx:latest\n    ports:\n      - \"80:80\"\n\n  db:\n    <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une image est une repr\u00e9sentation visuelle d'un objet ou d'une sc\u00e8ne, g\u00e9n\u00e9ralement compos\u00e9e de pixels dans les formats num\u00e9riques. Elle peut transmettre des informations, susciter des \u00e9motions et faciliter la communication \u00e0 travers diff\u00e9rents m\u00e9dias.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: postgres:latest\n    environment:\n      POSTGRES_DB: example_db\n      POSTGRES_USER: user\n      POSTGRES_PASSWORD: password\n\nnetworks:\n  default:\n    driver: bridge\n\nvolumes:\n  db_data:<\/code><\/pre>\n<h2>Plonger plus profond\u00e9ment : Comprendre chaque section<\/h2>\n<h3>Version<\/h3>\n<p>The version specifies which features of <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> you can use. Different versions may support different functionalities, such as <code>d\u00e9ployer<\/code> options dans la version 3 et les versions ult\u00e9rieures. Il est crucial de choisir une version qui s'aligne sur le <span class=\"glossaryai-tooltip glossary-term-666\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-engine\/\" target=\"_blank\">Moteur Docker<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Engine est une technologie de conteneurisation open source qui permet aux d\u00e9veloppeurs de cr\u00e9er, d\u00e9ployer et g\u00e9rer des applications au sein d'environnements l\u00e9gers et isol\u00e9s appel\u00e9s conteneurs.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-engine\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> version you are using.<\/p>\n<h3>Services<\/h3>\n<p>The services section is the heart of the <span class=\"glossaryai-tooltip glossary-term-689\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\" target=\"_blank\">fichier Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Un fichier Docker Compose est un fichier de configuration YAML qui d\u00e9finit les services, les r\u00e9seaux et les volumes pour les applications Docker multi-conteneurs. Il simplifie le d\u00e9ploiement et la gestion, am\u00e9liorant ainsi l'efficacit\u00e9.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-file\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Each <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can be configured with various options:<\/p>\n<h4>Image et contexte de construction<\/h4>\n<ul>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">Image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une image est une repr\u00e9sentation visuelle d'un objet ou d'une sc\u00e8ne, g\u00e9n\u00e9ralement compos\u00e9e de pixels dans les formats num\u00e9riques. Elle peut transmettre des informations, susciter des \u00e9motions et faciliter la communication \u00e0 travers diff\u00e9rents m\u00e9dias.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/strong>: Specifies the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une image est une repr\u00e9sentation visuelle d'un objet ou d'une sc\u00e8ne, g\u00e9n\u00e9ralement compos\u00e9e de pixels dans les formats num\u00e9riques. Elle peut transmettre des informations, susciter des \u00e9motions et faciliter la communication \u00e0 travers diff\u00e9rents m\u00e9dias.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to use for the <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. You can use images from <span class=\"glossaryai-tooltip glossary-term-653\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-hub\/\" target=\"_blank\">Docker Hub<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Hub is a cloud-based repository for storing and sharing container images. It facilitates version control, collaborative development, and seamless integration with Docker CLI for efficient container management.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-hub\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> or your private repositories.<\/p>\n<\/li>\n<li>\n<p><strong>Construire<\/strong>: If you want to build an <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une image est une repr\u00e9sentation visuelle d'un objet ou d'une sc\u00e8ne, g\u00e9n\u00e9ralement compos\u00e9e de pixels dans les formats num\u00e9riques. Elle peut transmettre des informations, susciter des \u00e9motions et faciliter la communication \u00e0 travers diff\u00e9rents m\u00e9dias.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> instead of pulling it, you can specify the build context and <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-yaml\">services:\napp:\n  build:\n    context: .\/app\n    <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>Variables d'environnement<\/h4>\n<p>Les variables d'environnement peuvent \u00eatre d\u00e9finies \u00e0 l'aide de <code>environnement<\/code> key. This is useful for configuring services without hardcoding values:<\/p>\n<pre><code class=\"language-yaml\">environment:\n  - DEBUG=true\n  - DATABASE_URL=mysql:\/\/user:password@db:3306\/dbname<\/code><\/pre>\n<h4>Ports<\/h4>\n<p>Tu peux <span class=\"glossaryai-tooltip glossary-term-676\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/expose\/\" target=\"_blank\">expose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"EXPOSE\" est un outil puissant utilis\u00e9 dans divers domaines, notamment la cybers\u00e9curit\u00e9 et le d\u00e9veloppement logiciel, pour identifier les vuln\u00e9rabilit\u00e9s et les lacunes des syst\u00e8mes, en veillant \u00e0 la mise en place de mesures de s\u00e9curit\u00e9 robustes.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/expose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> les ports de la machine h\u00f4te pour permettre l'acc\u00e8s externe aux services. La syntaxe est <code>HOST:<span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">CONTAINER<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code>.<\/p>\n<pre><code class=\"language-yaml\">ports:\n  - \"8080:80\"<\/code><\/pre>\n<h4>D\u00e9pendances<\/h4>\n<p>Parfois, les services d\u00e9pendent d'autres pour \u00eatre op\u00e9rationnels avant de pouvoir d\u00e9marrer. Le <code>d\u00e9pend_de<\/code> option allows you to specify dependencies:<\/p>\n<pre><code class=\"language-yaml\">depends_on:\n  - db<\/code><\/pre>\n<p>However, it is important to note that <code>d\u00e9pend_de<\/code> n'attend pas pour le\/la\/les <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to be &quot;ready&quot;\u2014only for it to be started.<\/p>\n<h3>Les r\u00e9seaux<\/h3>\n<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> creates a default <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\" target=\"_blank\">r\u00e9seau<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> for your services, but you can define custom networks for more granular control. Each <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can join multiple networks, and you can also define the driver (e.g., bridge, overlay) to use:<\/p>\n<pre><code class=\"language-yaml\">networks:\n  my_network:\n    driver: overlay<\/code><\/pre>\n<h3>Volumes<\/h3>\n<p>Volumes are essential for data persistence. When a <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is removed, its data is lost unless stored in a <span class=\"glossaryai-tooltip glossary-term-660\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/volume\/\" target=\"_blank\">volume<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Volume is a quantitative measure of three-dimensional space occupied by an object or substance, typically expressed in cubic units. It is fundamental in fields such as physics, chemistry, and engineering.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/volume\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Vous pouvez d\u00e9finir des volumes dans votre fichier Compose et les monter sur des chemins sp\u00e9cifiques \u00e0 l'int\u00e9rieur de vos conteneurs :<\/p>\n<pre><code class=\"language-yaml\">volumes:\n  db_data:<\/code><\/pre>\n<p>Le texte fourni est incomplet. Veuillez fournir la phrase compl\u00e8te pour une traduction pr\u00e9cise. <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-yaml\">db:\n  volumes:\n    - db_data:\/var\/lib\/postgresql\/data<\/code><\/pre>\n<h3>Extending Docker Compose Configurations<\/h3>\n<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> offers the ability to extend services, which is particularly useful in scenarios where you want to reuse configurations across multiple services.<\/p>\n<h4>En utilisant <code>\u00e9tend<\/code><\/h4>\n<p>To extend a <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, vous pouvez utiliser le <code>\u00e9tend<\/code> keyword. This allows you to inherit properties from another <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> defined in the same or a different Compose file:<\/p>\n<pre><code class=\"language-yaml\">version: '3.8'\n\nservices:\n  base:\n    image: nginx:latest\n    ports:\n      - \"80:80\"\n\n  app:\n    extends:\n      <span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>: base\n      file: common.yml<\/code><\/pre>\n<h3>Substitution de variables d'environnement<\/h3>\n<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> supports environment variable substitution, allowing you to define values outside of your Compose file. This is useful for sensitive data, such as <span class=\"glossaryai-tooltip glossary-term-1249\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/api\/\" target=\"_blank\">API<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une API, ou Interface de programmation, permet aux applications logicielles de communiquer et d'interagir entre elles. Elle d\u00e9finit des protocoles et des outils pour construire des logiciels et faciliter l'int\u00e9gration.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/api\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> keys or passwords:<\/p>\n<pre><code class=\"language-yaml\">environnement:\n  - DB_PASSWORD=${DB_PASSWORD}<\/code><\/pre>\n<p>You can set the environment variable in your shell before running <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, keeping your configuration files clean and secure.<\/p>\n<h2>Gestion des D\u00e9ploiements Multi-Environnements<\/h2>\n<p>In many real-world applications, different environments (development, testing, production) require different configurations. <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> makes it easy to manage this with multiple Compose files.<\/p>\n<h3>Using Multiple Compose Files<\/h3>\n<p>Vous pouvez cr\u00e9er des fichiers Compose distincts pour diff\u00e9rents environnements et utiliser le <code>-f<\/code> flag to specify which file to use when running <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> commands:<\/p>\n<pre><code class=\"language-bash\">docker-compose -f docker-compose.yml -f docker-compose.prod.yml up<\/code><\/pre>\n<p>This allows you to override or <span class=\"glossaryai-tooltip glossary-term-674\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/add\/\" target=\"_blank\">add<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">La commande ADD dans Docker est une instruction utilis\u00e9e dans les Dockerfiles pour copier des fichiers et des r\u00e9pertoires depuis une machine h\u00f4te vers une image Docker pendant le processus de construction. Elle facilite non seulement le transfert de fichiers locaux, mais offre \u00e9galement des fonctionnalit\u00e9s suppl\u00e9mentaires, telles que l'extraction automatique de fichiers compress\u00e9s et le t\u00e9l\u00e9chargement de fichiers distants via HTTP ou HTTPS.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/add\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> configurations specific to the environment.<\/p>\n<h3>Structure d'exemple<\/h3>\n<p>Voici comment vous pourriez organiser vos fichiers :<\/p>\n<pre><code>.\n\u251c\u2500\u2500 docker-compose.yml         # Base configuration\n\u251c\u2500\u2500 docker-compose.dev.yml     # Development-specific overrides\n\u2514\u2500\u2500 docker-compose.prod.yml     # Production-specific overrides<\/code><\/pre>\n<h2>Orchestrating with Docker Compose<\/h2>\n<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> provides a set of commands that allow you to manage your application lifecycle effectively.<\/p>\n<h3>Commandes courantes<\/h3>\n<ol>\n<li>\n<p><strong>Starting Services<\/strong>: Utilisez <code>docker-compose up<\/code> to start your services. The <code>-d<\/code> Le drapeau les ex\u00e9cute en mode d\u00e9tach\u00e9.<\/p>\n<\/li>\n<li>\n<p><strong>Arr\u00eat des services<\/strong>: Utilisez <code>docker-compose down<\/code> pour arr\u00eater et supprimer les conteneurs, les r\u00e9seaux et les volumes.<\/p>\n<\/li>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-696\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/scaling\/\" target=\"_blank\">Scaling<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Scaling refers to the process of adjusting the capacity of a system to accommodate varying loads. It can be achieved through vertical scaling, which enhances existing resources, or horizontal scaling, which adds additional resources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/scaling\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Services<\/strong>: Vous pouvez mettre \u00e0 l'\u00e9chelle vos services en utilisant les <code>--scale<\/code> option:<\/p>\n<pre><code class=\"language-bash\">docker-compose up --scale web=3<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>Viewing Logs<\/strong>: Utilisez <code>docker-compose logs<\/code> pour afficher les journaux de tous les services. <\/p>\n<\/li>\n<li>\n<p><strong>Executing Commands<\/strong>: Utilisez <code>docker-compose ex\u00e9cuter<\/code> to <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> commandes en cours d'ex\u00e9cution <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\" target=\"_blank\">conteneur<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-bash\">docker-compose exec app bash<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>Best Practices for Docker Compose Configurations<\/h2>\n<p>Pour vous assurer que votre <span class=\"glossaryai-tooltip glossary-term-1285\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-configurations\/\" target=\"_blank\">Docker Compose configurations<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Les configurations Docker Compose simplifient le d\u00e9ploiement d'applications multi-conteneurs en d\u00e9finissant les services, les r\u00e9seaux et les volumes dans un seul fichier YAML. Cette approche modulaire am\u00e9liore la scalabilit\u00e9 et la gestion.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-configurations\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Pour que votre code soit efficace et maintenable, suivez ces meilleures pratiques :<\/p>\n<ol>\n<li>\n<p><strong>Use Named Volumes<\/strong>: Always use named volumes for data persistence to avoid data loss and to make backups easier.<\/p>\n<\/li>\n<li>\n<p><strong>Keep Environments Separate<\/strong>: Use multiple Compose files to separate your environment configurations.<\/p>\n<\/li>\n<li>\n<p><strong>Use <code>.env<\/code> Files<\/strong>: Stockez les variables d'environnement dans un <code>.env<\/code> file to avoid hardcoding sensitive information in your Compose files.<\/p>\n<\/li>\n<li>\n<p><strong>Version Control<\/strong>: Contr\u00f4lez toujours la version de votre <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> files to track changes and collaborate effectively.<\/p>\n<\/li>\n<li>\n<p><strong><span class=\"glossaryai-tooltip glossary-term-681\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\" target=\"_blank\">Service<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Le service fait r\u00e9f\u00e9rence \u00e0 l'acte de fournir une assistance ou un soutien pour r\u00e9pondre \u00e0 des besoins ou des exigences sp\u00e9cifiques. Dans divers domaines, il englobe le service client, le support technique et les services professionnels, en mettant l'accent sur l'efficacit\u00e9 et la satisfaction de l'utilisateur.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/service\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Isolation<\/strong>: Keep services isolated and use light-weight images for better performance and security.<\/p>\n<\/li>\n<li>\n<p><strong>Contr\u00f4les de sant\u00e9<\/strong>: Implement health checks to ensure that your services are running correctly.<\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is an indispensable tool for managing multi-container applications, offering a clear and concise way to define, deploy, and manage services. By understanding its configuration structure, best practices, and commands, developers can leverage <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to streamline their workflows, enhance collaboration, and ensure consistency across different environments. Whether you are building a complex microservices architecture or a simple web application, mastering <span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> will significantly improve your development and deployment processes. The ability to define your entire application <span class=\"glossaryai-tooltip glossary-term-682\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/stack\/\" target=\"_blank\">pile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Une pile est une structure de donn\u00e9es qui fonctionne selon le principe du dernier entr\u00e9, premier sorti (LIFO), o\u00f9 l'\u00e9l\u00e9ment le plus r\u00e9cemment ajout\u00e9 est le premier \u00e0 \u00eatre retir\u00e9. Elle prend en charge deux op\u00e9rations principales : empiler et d\u00e9piler.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/stack\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Un fichier unique simplifie \u00e0 la fois le d\u00e9veloppement et les op\u00e9rations, en ad\u00e9quation avec les pratiques DevOps modernes.<\/p>","protected":false},"excerpt":{"rendered":"<p><span class=\"glossaryai-tooltip glossary-term-654\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\" target=\"_blank\">Docker Compose<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file. It simplifies deployment, configuration, and orchestration of services, enhancing development efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> <span class=\"glossaryai-tooltip glossary-term-688\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/config\/\" target=\"_blank\">Configuration<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Config refers to configuration settings that determine how software or hardware operates. It encompasses parameters that influence performance, security, and functionality, enabling tailored user experiences.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/config\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> simplifies multi-container application deployment by defining services, networks, and volumes in a single <span class=\"glossaryai-tooltip glossary-term-690\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/yaml\/\" target=\"_blank\">YAML<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">YAML (YAML Ain't Markup Language) is a human-readable data serialization format commonly used for configuration files. It emphasizes simplicity and clarity, making it suitable for both developers and non-developers.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/yaml\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> file. This approach enhances <span class=\"glossaryai-tooltip glossary-term-657\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\" target=\"_blank\">orchestration<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">L'orchestration d\u00e9signe la gestion et la coordination automatis\u00e9es de syst\u00e8mes et de services complexes. Elle optimise les processus en int\u00e9grant diverses composantes, en garantissant un fonctionnement efficace et une utilisation optimale des ressources.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/fr\/wiki\/orchestration\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> et garantit des environnements coh\u00e9rents.<\/p>","protected":false},"author":1,"featured_media":1570,"parent":0,"template":"","glossary-cat":[],"class_list":["post-1128","glossary","type-glossary","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Docker Compose Config - Dockerpros<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Compose Config - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"Docker Compose Config simplifies multi-container application deployment by defining services, networks, and volumes in a single YAML file. This approach enhances orchestration and ensures consistent environments.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-22T20:55:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/\",\"url\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/\",\"name\":\"Docker Compose Config - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg\",\"datePublished\":\"2024-07-22T20:41:23+00:00\",\"dateModified\":\"2024-07-22T20:55:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg\",\"width\":800,\"height\":600,\"caption\":\"docker-compose-config-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dockerpros.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Glossary\",\"item\":\"https:\/\/dockerpros.com\/fr\/wiki\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Docker Compose Config\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dockerpros.com\/#website\",\"url\":\"https:\/\/dockerpros.com\/\",\"name\":\"Dockerpros\",\"description\":\"DockerPros \u2013 Your Ultimate Docker Resource Hub\",\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dockerpros.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"width\":532,\"height\":114,\"caption\":\"Dockerpros\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Configuration Docker Compose - Dockerpros\n\nDocker Compose est un outil qui permet de d\u00e9finir et d'ex\u00e9cuter des applications multi-conteneurs. Il utilise un fichier YAML pour configurer les services de l'application. Ce fichier, appel\u00e9 docker-compose.yml, est utilis\u00e9 pour lancer et g\u00e9rer tous les conteneurs de l'application en une seule commande.\n\nDans ce tutoriel, nous allons explorer la configuration Docker Compose et apprendre \u00e0 cr\u00e9er un fichier docker-compose.yml pour une application simple.\n\nStructure du fichier docker-compose.yml\n\nLe fichier docker-compose.yml est un fichier YAML qui d\u00e9finit les services, les r\u00e9seaux et les volumes de votre application. Voici un exemple de base :\n\n```yaml\nversion: '3'\nservices:\n  web:\n    image: nginx:latest\n    ports:\n      - \"80:80\"\n    volumes:\n      - .\/html:\/usr\/share\/nginx\/html\n  db:\n    image: mysql:5.7\n    environment:\n      MYSQL_ROOT_PASSWORD: password\n      MYSQL_DATABASE: mydb\n    volumes:\n      - db_data:\/var\/lib\/mysql\n\nvolumes:\n  db_data:\n```\n\nDans cet exemple, nous avons deux services : web et db. Le service web utilise l'image nginx:latest et mappe le port 80 du conteneur au port 80 de l'h\u00f4te. Il monte \u00e9galement un volume pour partager des fichiers entre l'h\u00f4te et le conteneur. Le service db utilise l'image mysql:5.7 et d\u00e9finit des variables d'environnement pour la configuration de la base de donn\u00e9es. Il utilise \u00e9galement un volume nomm\u00e9 db_data pour persister les donn\u00e9es de la base de donn\u00e9es.\n\nD\u00e9marrage des services\n\nPour d\u00e9marrer les services d\u00e9finis dans le fichier docker-compose.yml, utilisez la commande suivante :\n\n```bash\ndocker-compose up\n```\n\nCette commande t\u00e9l\u00e9charge les images n\u00e9cessaires, cr\u00e9e les conteneurs et les d\u00e9marre. Vous pouvez \u00e9galement utiliser l'option -d pour ex\u00e9cuter les conteneurs en arri\u00e8re-plan :\n\n```bash\ndocker-compose up -d\n```\n\nArr\u00eat des services\n\nPour arr\u00eater les services, utilisez la commande suivante :\n\n```bash\ndocker-compose down\n```\n\nCette commande arr\u00eate et supprime les conteneurs, les r\u00e9seaux et les volumes d\u00e9finis dans le fichier docker-compose.yml.\n\nAutres commandes utiles\n\n- `docker-compose ps` : Liste les conteneurs en cours d'ex\u00e9cution.\n- `docker-compose logs` : Affiche les logs des conteneurs.\n- `docker-compose exec` : Ex\u00e9cute une commande dans un conteneur en cours d'ex\u00e9cution.\n- `docker-compose build` : Construit ou reconstruit les services.\n\nConclusion\n\nDocker Compose est un outil puissant pour g\u00e9rer les applications multi-conteneurs. En utilisant un fichier docker-compose.yml, vous pouvez d\u00e9finir et configurer facilement vos services, r\u00e9seaux et volumes. Avec les commandes docker-compose, vous pouvez d\u00e9marrer, arr\u00eater et g\u00e9rer vos conteneurs de mani\u00e8re efficace.\n\nJ'esp\u00e8re que ce tutoriel vous a aid\u00e9 \u00e0 comprendre la configuration Docker Compose. N'h\u00e9sitez pas \u00e0 exp\u00e9rimenter avec diff\u00e9rents services et configurations pour approfondir vos connaissances.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/","og_locale":"fr_FR","og_type":"article","og_title":"Docker Compose Config - Dockerpros","og_description":"Docker Compose Config simplifies multi-container application deployment by defining services, networks, and volumes in a single YAML file. This approach enhances orchestration and ensures consistent environments.","og_url":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/","og_site_name":"Dockerpros","article_modified_time":"2024-07-22T20:55:31+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/","url":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/","name":"Configuration Docker Compose - Dockerpros\n\nDocker Compose est un outil qui permet de d\u00e9finir et d'ex\u00e9cuter des applications multi-conteneurs. Il utilise un fichier YAML pour configurer les services de l'application. Ce fichier, appel\u00e9 docker-compose.yml, est utilis\u00e9 pour lancer et g\u00e9rer tous les conteneurs de l'application en une seule commande.\n\nDans ce tutoriel, nous allons explorer la configuration Docker Compose et apprendre \u00e0 cr\u00e9er un fichier docker-compose.yml pour une application simple.\n\nStructure du fichier docker-compose.yml\n\nLe fichier docker-compose.yml est un fichier YAML qui d\u00e9finit les services, les r\u00e9seaux et les volumes de votre application. Voici un exemple de base :\n\n```yaml\nversion: '3'\nservices:\n  web:\n    image: nginx:latest\n    ports:\n      - \"80:80\"\n    volumes:\n      - .\/html:\/usr\/share\/nginx\/html\n  db:\n    image: mysql:5.7\n    environment:\n      MYSQL_ROOT_PASSWORD: password\n      MYSQL_DATABASE: mydb\n    volumes:\n      - db_data:\/var\/lib\/mysql\n\nvolumes:\n  db_data:\n```\n\nDans cet exemple, nous avons deux services : web et db. Le service web utilise l'image nginx:latest et mappe le port 80 du conteneur au port 80 de l'h\u00f4te. Il monte \u00e9galement un volume pour partager des fichiers entre l'h\u00f4te et le conteneur. Le service db utilise l'image mysql:5.7 et d\u00e9finit des variables d'environnement pour la configuration de la base de donn\u00e9es. Il utilise \u00e9galement un volume nomm\u00e9 db_data pour persister les donn\u00e9es de la base de donn\u00e9es.\n\nD\u00e9marrage des services\n\nPour d\u00e9marrer les services d\u00e9finis dans le fichier docker-compose.yml, utilisez la commande suivante :\n\n```bash\ndocker-compose up\n```\n\nCette commande t\u00e9l\u00e9charge les images n\u00e9cessaires, cr\u00e9e les conteneurs et les d\u00e9marre. Vous pouvez \u00e9galement utiliser l'option -d pour ex\u00e9cuter les conteneurs en arri\u00e8re-plan :\n\n```bash\ndocker-compose up -d\n```\n\nArr\u00eat des services\n\nPour arr\u00eater les services, utilisez la commande suivante :\n\n```bash\ndocker-compose down\n```\n\nCette commande arr\u00eate et supprime les conteneurs, les r\u00e9seaux et les volumes d\u00e9finis dans le fichier docker-compose.yml.\n\nAutres commandes utiles\n\n- `docker-compose ps` : Liste les conteneurs en cours d'ex\u00e9cution.\n- `docker-compose logs` : Affiche les logs des conteneurs.\n- `docker-compose exec` : Ex\u00e9cute une commande dans un conteneur en cours d'ex\u00e9cution.\n- `docker-compose build` : Construit ou reconstruit les services.\n\nConclusion\n\nDocker Compose est un outil puissant pour g\u00e9rer les applications multi-conteneurs. En utilisant un fichier docker-compose.yml, vous pouvez d\u00e9finir et configurer facilement vos services, r\u00e9seaux et volumes. Avec les commandes docker-compose, vous pouvez d\u00e9marrer, arr\u00eater et g\u00e9rer vos conteneurs de mani\u00e8re efficace.\n\nJ'esp\u00e8re que ce tutoriel vous a aid\u00e9 \u00e0 comprendre la configuration Docker Compose. N'h\u00e9sitez pas \u00e0 exp\u00e9rimenter avec diff\u00e9rents services et configurations pour approfondir vos connaissances.","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg","datePublished":"2024-07-22T20:41:23+00:00","dateModified":"2024-07-22T20:55:31+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-compose-config_1128.jpg","width":800,"height":600,"caption":"docker-compose-config-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/fr\/wiki\/docker-compose-config\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dockerpros.com\/"},{"@type":"ListItem","position":2,"name":"Glossary","item":"https:\/\/dockerpros.com\/fr\/wiki\/"},{"@type":"ListItem","position":3,"name":"Docker Compose Config"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Dockerpros","description":"DockerPros \u2013 Votre centre de ressources Docker incontournable","publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dockerpros.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Dockerpros","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","width":532,"height":114,"caption":"Dockerpros"},"image":{"@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary\/1128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary\/1128\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media\/1570"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/media?parent=1128"}],"wp:term":[{"taxonomy":"glossary-cat","embeddable":true,"href":"https:\/\/dockerpros.com\/fr\/wp-json\/wp\/v2\/glossary-cat?post=1128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}