docker-compose编排工具
安装docker-compose
[root@service ~]# systemctl stop firewalld
[root@service ~]# setenforce 0
[root@service ~]# systemctl start docker
[root@service ~]# wget https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64
--2024-03-20 13:43:28-- https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64
正在解析主机 github.com (github.com)... 20.205.243.166
正在连接 github.com (github.com)|20.205.243.166|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/ff4c52bc-2caf-4248-a74c-3df2accb02d9?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240320T054152Z&X-Amz-Expires=300&X-Amz-Signature=421843867085c13bfbd10a9d37339d5bdfac4b34d3cbabe56b05b687594e9c67&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=15045751&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-x86_64&response-content-type=application%2Foctet-stream [跟随至新的 URL]
--2024-03-20 13:43:29-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/ff4c52bc-2caf-4248-a74c-3df2accb02d9?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240320T054152Z&X-Amz-Expires=300&X-Amz-Signature=421843867085c13bfbd10a9d37339d5bdfac4b34d3cbabe56b05b687594e9c67&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=15045751&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-x86_64&response-content-type=application%2Foctet-stream
正在解析主机 objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.108.133, ...
正在连接 objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:26525696 (25M) [application/octet-stream]
正在保存至: “docker-compose-linux-x86_64”
docker-compose-linux-x86_64 100%[=======================================================================================>] 25.30M 599KB/s 用时 40s
2024-03-20 13:44:10 (644 KB/s) - 已保存 “docker-compose-linux-x86_64” [26525696/26525696])
[root@service ~]# mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
[root@service ~]# chmod a+x /usr/local/bin/docker-compose
创建目录
[root@service ~]# cd /opt/
[root@service opt]# mkdir docker-compose
[root@service opt]# cd docker-compose/
[root@service docker-compose]# mkdir wordpress
编排启动镜像
[root@service docker-compose]# vim docker-compose.yaml
services:
db:
image: mysql:5.7
volumes:
- /data/db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- /data/web_data:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
[root@service docker-compose]# docker-compose up -d
Docker Compose 卸载
sudo rm /usr/local/bin/docker-compose
pip uninstall docker-compose