docker-compose安装

 

作者:Lion Long
链接:https://www.zhihu.com/question/485747466/answer/2960561655
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

docker compose的安装和卸载1、安装在 Linux 上的也安装十分简单,从 GitHub Release处直接下载编译好的二进制文件即可。例如,在 Linux 64 位系统上直接下载对应的二进制包。(1)先把docker-compose文件下载到当前目录:

 

wget https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64

然后拷贝到/usr/bin/ 

sudo cp -arf docker-compose-linux-x86_64 /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose

 

卸载如果是二进制包方式安装的,删除二进制文件即可。

sudo rm /usr/bin/docker-compose3、

使用选项:

Usage: docker compose [OPTIONS] COMMAND

Docker Compose

Options:
--ansi string Control when to print ANSI control characters ("never"|"always"|"auto") (default "auto")
--compatibility Run compose in backward compatibility mode
--env-file string Specify an alternate environment file.
-f, --file stringArray Compose configuration files
--profile stringArray Specify a profile to enable
--project-directory string Specify an alternate working directory
(default: the path of the, first specified, Compose file)
-p, --project-name string Project name

Commands:
build Build or rebuild services
convert Converts the compose file to platform's canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service.
down Stop and remove containers, networks
events Receive real time events from containers.
exec Execute a command in a running container.
images List images used by the created containers
kill Force stop service containers.
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding.
ps List containers
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service.
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information

Run 'docker compose COMMAND --help' for more information on a command.compose的关键选项:-p:指定项目名称。-f:指定配置文件。建议:单独的项目放在一个文件夹下,而不指定-p和-f参数,这样用起来比较方便;因为如果指定这两个选项,那么在项目操作过程中需要每次都要指定这两个参数,否则compose指令就识别不到项目。所以直接以默认的方式(以当前文件夹作为项目名称,当前文件夹下的docker-compose.yml作为配置文件)执行。<img src="https://pic1.zhimg.com/50/v2-c67c5682e92b976cc834d967b3b574e4_720w.jpg?source=1940ef5c" data-caption="" data-size="normal" data-rawwidth="1080" data-rawheight="300" data-original-token="v2-c67c5682e92b976cc834d967b3b574e4" data-default-watermark-src="https://pic1.zhimg.com/50/v2-0b4332e8627e5763b016208b3b195686_720w.jpg?source=1940ef5c" class="origin_image zh-lightbox-thumb" width="1080" data-original="https://picx.zhimg.com/v2-c67c5682e92b976cc834d967b3b574e4_r.jpg?source=1940ef5c"/>

posted on 2023-09-04 12:50  是水饺不是水饺  阅读(37)  评论(0)    收藏  举报

导航