Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Compose in Docker

Shulou Source: shulou.com Published: 2022-06-02 05:49:25 09月14日 Update

I believe many inexperienced people don't know what to do about how to use Compose in Docker. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Brief introduction:

Compose is a tool software developed by Docker company, which can manage multiple Docker containers to form an application. You need to define a configuration file docker-compose.yml in YAML format and write the invocation relationship between many containers. Then, with a single command, you can start / close these containers at the same time.

# start all services $docker-compose up# shut down all services $docker-compose stop installation:

When Mac and Windows install docker, they install docker compose together. Refer to the official documentation for installation under the Linux system

Check whether the installation is successful: $docker-compose-- version

Use:

A standard docker-compose.yml file should contain three parts: version, services and networks, the most important of which are services and networks.

Docker runs commands to convert to docker-compose.yml instances

The docker command executes 2 mirrors:

Docker run-d-p 9020 sysctl net.core.somaxconn=4096 registry.leyantech.com/infra/wp-apidocker run-d-p 88:80 registry.leyantech.com/infra/wp-vue

Convert to docker-compose:

Version: "3" services: wp-vue: image: registry.leyantech.com/infra/wp-vue ports:-"88:80" volumes:-/ data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf-/ data/nginx/conf.d:/etc/nginx/conf.d-/ data/nginx/logs:/var/log/nginx restart: always wp-api: image : registry.leyantech.com/infra/wp-api sysctls:-net.core.somaxconn=4096 ports:-"9020 restart: always read the above content Have you mastered how to use Compose in Docker? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Commands containers content multiple files methods more parts problems services success helplessness for this big three two between company key reason at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL Microsoft Redmi Shulou Technology