Skip to content

Compose 是用于定义和运行多容器 Docker 应用程序的工具。通过 Compose,您可以使用 YML 文件来配置应用程序需要的所有服务。然后,使用一个命令,就可以从 YML 文件配置中创建并启动所有服务。

安装

terminal
bash
# 安装扩展源
$ sudo yum -y install epel-release

# 安装python-pip模块
$ sudo yum install python-pip

# 注:Centos 8已经换成python3
$ sudo yum install python3-pip


# 通过以命令进行安装

# 方式一
$ cd /usr/local/bin/

$ wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64

$ rename docker-compose-Linux-x86_64 docker-compose docker-compose-Linux-x86_64

# 方式二
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# 更改权限
$ chmod +x /usr/local/bin/docker-compose

# 打印输入信息
$ docker-compose version

卸载

terminal
bash
# 如果通过 curl 命令安装 Docker Compose:
$ sudo rm /usr/local/bin/docker-compose

# 如果通过 pip 命令安装 Docker Compose:
$ pip uninstall docker-compose

常见命令

terminal
bash
# 列出所有运行容器
$ docker-compose ps

# 查看服务日志输出
$ docker-compose logs

# 打印绑定的公共端口,例如:输出 eureka 服务 8761 端口所绑定的公共端口
$ docker-compose port eureka 8761

# 构建或者重新构建服务
$ docker-compose build

# 启动指定服务已存在的容器
$ docker-compose start eureka

# 停止已运行的服务的容器
$ docker-compose stop eureka

# 删除指定服务的容器
$ docker-compose rm eureka

# 构建、启动容器(-d:表示在后台运行)
$ docker-compose up

# 通过发送 SIGKILL 信号来停止指定服务的容器
$ docker-compose kill eureka

# 下载服务镜像

# 设置指定服务运气容器的个数,以 service=num 形式指定
$ docker-compose scale user=3 movie=3

# 在一个服务上执行一个命令
$ docker-compose run web bash

问题记录

https://stackoverflow.com/questions/58747879/docker-compose-usr-local-bin-docker-compose-line-1-not-command-not-found

Layout Switch

Adjust the layout style of VitePress to adapt to different reading needs and screens.

Expand all
The sidebar and content area occupy the entire width of the screen.
Expand sidebar with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Expand all with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Original width
The original layout width of VitePress

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.

Spotlight

Highlight the line where the mouse is currently hovering in the content to optimize for users who may have reading and focusing difficulties.

ONOn
Turn on Spotlight.
OFFOff
Turn off Spotlight.