In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How is compose used in docker? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Install docker-compose:
The copy code is as follows:
Curl-L https://github.com/docker/compose/release/download/1.6.0/docker-compose-`uname-s`-`uname-r` > / usr/local/bin/docker-composechmod + x / usr/local/bin/docker-compose
To manage multiple containers using Docker Compose, you first need to write the container to its configuration file. The default configuration file is called docker-compose.yml, and we can specify the configuration file with the "- f" option.
The following is explained by installing redmine
Transform docker run's instructions to create containers into Docker Compose configuration files
The commands to create and launch the postgresql container are:
[root@localhost] # docker run-- name postgresql-redmine-d\ >-- env 'DB_NAME=redmine_production'\ >-- env' DB_USER=redmine'\ >-- env 'DB_PASS=password'\ > sameersbn/postgresql:9.4-12
It uses the sameersbn/postgresql:9.4-12 image to create a container named postgresql-redmine and configures three environment variables. The conversion to Docker Compose configuration file is as follows:
Postgresql: image: sameersbn/postgresql:9.4-12 environment:-DB_NAME=readmine_production-DB_USER=redmine-DB_PASS=password
The commands to create and launch the redmine container are:
The copy code is as follows:
Docker run-- name redmine-d-- link postgresql-redmine:postgresql-- publish 10083 link postgresql-redmine:postgresql 80-- env 'REDMINE_PORT=10083' sameersbn/redmine:3.2.0-4
It uses sameersbn/redmine:3.2.0-4 image to create a container named redmine, which is converted to Docker Compose configuration file as follows:
Redmine: image: sameersbn/redmine:3.2.0-4 links:-postgresql:postgresql ports:-"10083 sameersbn/redmine:3.2.0 80" environment:-REDMINE_PORT=10083
Create a configuration file ~ / redmine/docker-compose.yml, and merge it as follows:
Postgresql: image: sameersbn/postgresql:9.4-12 environment:-DB_NAME=readmine_production-DB_USER=redmine-DB_PASS=password redmine: image: sameersbn/redmine:3.2.0-4 links:-postgresql:postgresql ports:-"10083 environment 80" environment:-REDMINE_PORT=10083
Perform the creation and startup of the new container group:
Docker-compose up-d
Finally, the website can be accessed through http://ip10083.
Subsequent starts and stops become very simple:
Stop the command:
Docker-compose stop
Start the command:
This is the answer to docker-compose start's question about how to use compose in docker. I hope the above content can be of some help to you. If you still have a lot of questions to solve, 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.