Ubuntu下docker以及docker-compose安装

Ubuntu下docker以及docker-compose安装

Docker

// 使用官方脚本自动安装
curl -fsSL https://test.docker.com -o get-docker.sh
sudo sh get-docker.sh

如果要使用 Docker 作为非 root 用户,则应考虑使用类似以下方式将用户添加到 docker 组:

$ sudo usermod -aG docker your-user

卸载 docker

删除安装包:

sudo apt-get purge docker-ce

删除镜像、容器、配置文件等内容:

sudo rm -rf /var/lib/docker

使用 Pip 安装 Docker Compose

或许,我们可以使用 Pip 安装 Docker Compose 。Pip 是 Python 包管理器,用来安装使用 Python 编写的应用程序。

参考下列链接安装 Pip 。

安装 Pip 后,运行以下命令安装 Docker Compose。下列命令对于所有 Linux 发行版都是相同的!

复制

$ pip install docker-compose

安装 Docker Compose 后,使用下列命令检查版本:

复制

$ docker-compose --version

你将会看到类似下方的输出:

复制

docker-compose version 1.29.2, build unknown

我在服务器上使用pip安装Python的库时直接报错,即使输入pip 也会直接报错,报错如下:

File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

问题原因

pyOpenSSL版本与python版本不匹配

解决方法

# 卸载pip
sudo apt-get remove python3-pip
# 下载pip
wget https://files.pythonhosted.org/packages/4b/30/e15b806597e67057e07a5acdc135216ccbf76a5f1681a324533b61066b0b/pip-22.2.2.tar.gz
# 解压
tar xf pip-22.2.2.tar.gz
# 安装
cd pip-22.2.2
python3 setup.py install
# 查询版本
root@ubuntu:/home/ubuntu/# pip3 --version
pip 22.2.2 from /usr/local/lib/python3.8/dist-packages/pip-22.2.2-py3.8.egg/pip (python 3.8)
# 软连接
ln /usr/local/bin/pip /usr/bin/pip

安装匹配的 pyOpenSSL

root@ubuntu:/home/ubuntu/# pip3 install pyOpenSSL --upgrade
Requirement already satisfied: pyOpenSSL in /usr/lib/python3/dist-packages (19.0.0)
Collecting pyOpenSSL
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0xffff968926a0>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/b7/6d/d7377332703ffd8821878794aca4fb54637da654bf3e467ffb32109c2147/pyOpenSSL-23.1.1-py3-none-any.whl
Downloading pyOpenSSL-23.1.1-py3-none-any.whl (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.9/57.9 kB 252.1 kB/s eta 0:00:00
Requirement already satisfied: cryptography<41,>=38.0.0 in /usr/local/lib/python3.8/dist-packages (from pyOpenSSL) (40.0.2)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.8/dist-packages (from cryptography<41,>=38.0.0->pyOpenSSL) (1.15.1)
Requirement already satisfied: pycparser in /usr/local/lib/python3.8/dist-packages (from cffi>=1.12->cryptography<41,>=38.0.0->pyOpenSSL) (2.21)
Installing collected packages: pyOpenSSL
Attempting uninstall: pyOpenSSL
Found existing installation: pyOpenSSL 19.0.0
Uninstalling pyOpenSSL-19.0.0:
Successfully uninstalled pyOpenSSL-19.0.0
Successfully installed pyOpenSSL-23.1.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
posted @ 2024-02-05 12:28  春游去动物园  阅读(932)  评论(0编辑  收藏  举报