Docker-Compose基礎

Scott_^發表於2020-10-17

1、Docker基礎

一、安裝docker for centos

官網

1.解除安裝舊的docker

sudo yum -y remove docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker

官網:

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2.安裝需要的軟體包

sudo yum install -y yum-utils

3.yum新增映象地址

國外:

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

阿里雲

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4.更新yum軟體包索引

sudo yum makecache fast

5.安裝docker CE

sudo yum install docker-ce docker-ce-cli containerd.io

6.啟動docker

systemctl start docker

7.測試命令

docker version
sudo docker run hello-world

8.配置docker映象加速

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://c1206fzd.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

2、Docker Compose

一、安裝

國內映象:

curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

賦權

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

如果發生如下報錯:

/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.

則執行下面的命令:

報錯詳情

pip uninstall pyrsistent
pip install pyrsistent==0.16.0

檢驗是否安裝成功

docker-compose version

相關文章