Linux中安装/部署docker-compose

简介: **必须要有docker**,如果没有可以去查看:[linux(centos)中部署docker(步骤超全,含带一些发展史和一些概念)]

@[toc]

前提

必须要有docker,如果没有可以去查看:linux(centos)中部署docker(步骤超全,含带一些发展史和一些概念),有安装步骤。
在这里插入图片描述

两种安装/部署方式

在这里插入图片描述

第一种:按照官方文档下载docker-compose包来安装

(1)下载docker-compose

执行如下命令进行下载

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

若速度较慢,可以使用如下命令:

curl -L "https://mirror.ghproxy.com/https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

(2)修改目录权限

chmod  x /usr/local/bin/docker-compose

(3)创建软连接

ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

(4)验证安装是否完成

执行如下命令,如果可以正常显示版本号,则表示已经完成

docker-compose --version

在这里插入图片描述

第二种:使用pip install 的方式安装

因为docker-compose是使用python开发的,因此可以通过pip install 的方式安装

(1)首先需要确保pip已经安装完成,如下

如下,表示pip为基于python3.9的版本,这里最好安装基于python3.6以上的pip

这里有安装文档:Linux下安装Python3.6.8(超级详细),可以采纳。

[root@localhost ~]# pip3 --version
pip 21.2.4 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)

(2)升级pip的版本

python3 -m pip install --upgrade pip

如:

[root@localhost ~]# python3 -m pip install --upgrade pip
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Requirement already satisfied: pip in /usr/local/python3/lib/python3.9/site-packages (21.2.4)
Collecting pip
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 105 kB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.4
    Uninstalling pip-21.2.4:
      Successfully uninstalled pip-21.2.4
  WARNING: The scripts pip, pip3 and pip3.9 are installed in '/usr/local/python3/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.3.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

(3)安装docker-compose

pip3 install docker-compose

如下:

[root@localhost ~]# pip3 install docker-compose
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Requirement already satisfied: docker-compose in /usr/local/python3/lib/python3.9/site-packages (1.29.2)
Requirement already satisfied: docker[ssh]>=5 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (5.0.3)
Requirement already satisfied: PyYAML<6,>=3.10 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (5.4.1)
Requirement already satisfied: jsonschema<4,>=2.5.1 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (3.2.0)
Requirement already satisfied: python-dotenv<1,>=0.13.0 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (0.19.1)
Requirement already satisfied: texttable<2,>=0.9.0 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (1.6.4)
Requirement already satisfied: websocket-client<1,>=0.32.0 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (0.59.0)
Requirement already satisfied: distro<2,>=1.5.0 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (1.6.0)
Requirement already satisfied: docopt<1,>=0.6.1 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (0.6.2)
Requirement already satisfied: dockerpty<1,>=0.4.1 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (0.4.1)
Requirement already satisfied: requests<3,>=2.20.0 in /usr/local/python3/lib/python3.9/site-packages (from docker-compose) (2.26.0)
Requirement already satisfied: paramiko>=2.4.2 in /usr/local/python3/lib/python3.9/site-packages (from docker[ssh]>=5->docker-compose) (2.8.0)
Requirement already satisfied: six>=1.3.0 in /usr/local/python3/lib/python3.9/site-packages (from dockerpty<1,>=0.4.1->docker-compose) (1.16.0)
Requirement already satisfied: attrs>=17.4.0 in /usr/local/python3/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (21.2.0)
Requirement already satisfied: pyrsistent>=0.14.0 in /usr/local/python3/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (0.18.0)
Requirement already satisfied: setuptools in /usr/local/python3/lib/python3.9/site-packages (from jsonschema<4,>=2.5.1->docker-compose) (57.4.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/python3/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (1.26.6)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/python3/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (2.0.7)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/python3/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/python3/lib/python3.9/site-packages (from requests<3,>=2.20.0->docker-compose) (2021.5.30)
Requirement already satisfied: cryptography>=2.5 in /usr/local/python3/lib/python3.9/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (35.0.0)
Requirement already satisfied: pynacl>=1.0.1 in /usr/local/python3/lib/python3.9/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (1.4.0)
Requirement already satisfied: bcrypt>=3.1.3 in /usr/local/python3/lib/python3.9/site-packages (from paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (3.2.0)
Requirement already satisfied: cffi>=1.1 in /usr/local/python3/lib/python3.9/site-packages (from bcrypt>=3.1.3->paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (1.15.0)
Requirement already satisfied: pycparser in /usr/local/python3/lib/python3.9/site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko>=2.4.2->docker[ssh]>=5->docker-compose) (2.20)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

(4)验证是否安装完成

docker-compose -version

如下

[root@localhost ~]# docker-compose -version
docker-compose version 1.29.2, build unknown

总结

相关文章:

①、 Docker——denied: requested access to the resource is denied问题以及解决方法
②、 Docker搭建harbor私有镜像仓库(命令行模式)
③、 Linux中基于Docker搭建harbor私有镜像仓库(超级详细)🔥🔥
④、 Docker发布/上传镜像到dockerhub&&下载/拉取镜像&&删除dockerhub镜像
目录
相关文章
|
4天前
|
NoSQL 关系型数据库 应用服务中间件
docker基础篇:安装tomcat
docker基础篇:安装tomcat
100 64
|
4天前
|
Linux Python
Linux 安装python3.7.6
本教程介绍在Linux系统上安装Python 3.7.6的步骤。首先使用`yum`安装依赖环境,包括zlib、openssl等开发库。接着通过`wget`下载Python 3.7.6源码包并解压。创建目标文件夹`/usr/local/python3`后,进入解压目录执行配置、编译和安装命令。最后设置软链接,使`python3`和`pip3`命令生效。
|
6天前
|
关系型数据库 MySQL 数据库
docker高级篇(大厂进阶):安装mysql主从复制
docker高级篇(大厂进阶):安装mysql主从复制
60 24
|
7天前
|
NoSQL 算法 Redis
docker高级篇(大厂进阶):安装redis集群
docker高级篇(大厂进阶):安装redis集群
58 24
|
7天前
|
Ubuntu Linux
Linux 各发行版安装 ping 命令指南
如何在不同 Linux 发行版(Ubuntu/Debian、CentOS/RHEL/Fedora、Arch Linux、openSUSE、Alpine Linux)上安装 `ping` 命令,详细列出各发行版的安装步骤和验证方法,帮助系统管理员和网络工程师快速排查网络问题。
69 20
|
5天前
|
Ubuntu Linux Docker
Ubuntu22.04上Docker的安装
通过以上详细的安装步骤和命令,您可以在Ubuntu 22.04系统上顺利安装
64 11
|
1月前
|
人工智能 API 数据安全/隐私保护
使用 Docker 一键免费部署 63.8k 的私人 ChatGPT 网页应用
NextChat 是一个可以在 GitHub 上一键免费部署的私人 ChatGPT 网页应用,支持 GPT3、GPT4 和 Gemini Pro 模型。该项目在 GitHub 上获得了 63.8k 的 star 数。部署简单,只需拉取 Docker 镜像并运行容器,设置 API Key 后即可使用。此外,NextChat 还提供了预设角色的面具功能,方便用户快速创建对话。
166 22
使用 Docker 一键免费部署 63.8k 的私人 ChatGPT 网页应用
|
1月前
|
缓存 Linux Docker
【最新版正确姿势】Docker安装教程(简单几步即可完成)
之前的老版本Docker安装教程已经发生了变化,本文分享了Docker最新版安装教程,其他操作系统版本也可以参考官 方的其他安装版本文档。
1288 2
【最新版正确姿势】Docker安装教程(简单几步即可完成)
|
7天前
|
Unix Linux 编译器
UNIX/Linux 上的安装
UNIX/Linux 上的安装。
23 2
|
22天前
|
Java 应用服务中间件 Docker
将基于 Spring 的 WAR 应用程序部署到 Docker:详尽指南
将基于 Spring 的 WAR 应用程序部署到 Docker:详尽指南
26 2