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

What is the use of DockerFile and docker-compose.yml

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the relevant knowledge of "DockerFile and docker-compose.yml". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

DockerFile is a file used to construct your own image, from which images can be generated. docker build -f DockerFile -t myImage . (Don't forget the point)

DockerFile example:

1 #Build images(mirror) using 2 FROM golang3 WORKDIR /go/src/4 COPY yxdzb .5 COPY script.sh EXPOSE 80807 CMD ["/bin/bash", "/go/src/script.sh"]

docker-compose.yml is the file used to orchestrate the configuration service (or container)(you can configure the startup container without this file). Typical command: docker-compose up -d

docker-compose.yml Example:

#orchestration services (containers), each service starts a mirror version: '3'services: mysql: ##(service1) restart: always image: mysql:5.7 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: "12345678" volumes: #data persistence, falling to local disk Local:docker container - mysqldb:/var/lib/mysql #label:docker container This way you don't know the absolute path stored locally, you need to use docker volume ls and docker volume inspect container labels to view. docker volume rm container label delete volume - ./ docker/mysql/my.cnf:/etc/my.cnf #label: container This is the way to use the local absolute path, you can view the specific path where the data is stored locally - ./ docker/mysql/init:/docker-entrypoint-initdb.d/ go-web: ##(Service 2) restart: always image: beego-web ports: - "8080:8080""DockerFile and docker-compose.yml What's the use" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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