Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write docker-compose file

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to write docker-compose files". In daily operation, I believe many people have doubts about how to write docker-compose documents. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts of "how to write docker-compose documents". Next, please follow the editor to study!

What is docker-compose?

Docker-compose is a tool for defining and running multi-container Docker applications.

Preparation stage

Docker and docker-compose are already installed.

Web1 and web2 images have been made and pushed to the remote repository.

Write docker-compose files and orchestrate services

1. Image: it is your docker image.

2. Depends_on: represents that web2 itself depends on web1, so web1 starts before web2 service

3. Volumes: can correspond to-v home/path/:/docker/path in docker operation

Version: '1'services: web1: image: docker.shj.com/shj/web1:v1 ports:-"8088 image 8080" volumes:-/ home/logs/:/usr/local/tomcat/logs/-/ home/logs/:/home/logs/ web2: image: docker.shj.com/shj/web2:v1 depends_on: -web1 volumes:-/ home/logs/:/usr/local/tomcat/logs/-/ home/logs/:/home/logs/ ports:-"8089Jap8080" mysql: environment: MYSQL_ROOT_PASSWORD: "shj@123" MYSQL_USER: "root" MYSQL_ PASS: "shj@123" image: docker.shj.com/ops/mysql:5.7 ports:-"33306 image 3306" nginx: image: docker.shj.com/ops/nginx:v1 volumes:-/ home/logs/nginx/:/home/logs/nginx/-/ home/shj/nginx/nginx_ssl/:/home/nginx/nginx / conf/cert/ssl/-/ home/shj/nginx/nginx_conf/:/usr/local/nginx/conf/http_vhost/-/ home/shj/web/web2/:/home/shj/apps/web/web2/-/ home/shj/web/web1/:/home/shj/apps/web/web1/ ports:-80:80. The study on "how to write docker-compose files" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report