In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is the Docker Compose yml file? in view of this question, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and easy way.
If we have an App, which consists of multiple container, then the maintenance of this App will be very cumbersome.
These include:
To pull image from Dockerfile build image or Docker hub
To create multiple container
To manage these container (start, stop, delete)
The function of docker Compose is "batch processing". We only need one command to manage the creation of multiple containers and stop deleting.
Docker Compose is a tool
This tool can define multi-container docker applications through a yml file.
The multiple containers can be created or managed according to the definition of the yml file with a single command.
How to write a yml file? Services
A service represents a container, which can be created from the image of the docker hub or from the image from the local Dockerfile build.
The startup of service is similar to docker run, and we can specify network and volume to it, so we can specify references to etwork and volume to service.
Example 1: services: db: image: postgres:9.4 volumes:-"db-data:/var/lib/postgresql/data" networks:-back-tier
This sentence is similar to
Docker run-d-name db--network back-tier-v db-data:/var/lib/postgresql/data postgres:9.4
Example 2: services: worker: build:. / worker networks: back-tier
This is through the local build.
Networksvolumes example: version: '3'services: wordpress: image: wordpress ports:-8080 wordpress 80 environment: WORDPRESS_DB_HOST: mysql WORDPRESS_DB_PASSWORD: root networks:-my-bridge mysql: image: mysql environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: wordpress volumes:-mysql-data:/var/lib/mysql networks:-my-bridgevolumes: mysql- Data:networks: my-bridge: driver: bridge
Version: "3" indicates that the version of docker Compose used is 3
This docker-compose.yml file contains three parts: services,volumes,networks
Services, which defines two service, wordpress and mysql. The wordpress port is 80 to 8080. The environment is equivalent to the-e option, and network indicates that the linked network is my-bridge, which will be defined below. The volume in mysql maps to mysql-data, and this volume is defined below.
The answer to the question about what the Docker Compose yml file is is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.