拿到新的服务器,第一件事情,更新数据源,ubuntu系统可以通过执行如下指令:
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list && \
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list && \
apt-get update -y && \
apt-get clean
debian系统如下:
cat >/etc/apt/sources.list <<EOF
deb http://mirrors.aliyun.com/debian stable main contrib non-free
deb http://mirrors.aliyun.com/debian stable-proposed-updates main contrib non-free
deb http://mirrors.aliyun.com/debian stable-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian stable main contrib non-free
deb-src http://mirrors.aliyun.com/debian stable-proposed-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian stable-updates main contrib non-free
EOF
更新:
root@xyxypi:apt update
root@xyxypi:~# apt upgrade
注意:如果执行失败,查一下内核
root@aml://# sudo dpkg --print-architecture
arm64
如果返回时arm架构,是因为Ubuntu 18.04 使用apt-get 华为源支持 arm64 鲲鹏处理器,而阿里云163等等的,都不支持arm64,所以需要如下指令更新源:
wget -O /etc/apt/sources.list https://repo.huaweicloud.com/repository/conf/Ubuntu-Ports-bionic.list
apt-get update
>> curl -fsSL get.docker.com -o get-docker.sh
>> sh get-docker.sh --mirror AzureChinaCloud
如果是debian 系统,则参考:
debian duocker安装
执行成功之后docker即安装成功,此时要更新docker镜像源daemon.json 文件
执行cd // 退到服务器主目录,执行 find -name "daemon.json" 找到自己的 daemon.json文件,一般在/etc/docker/daemon.json 目录下,然后执行vi /etc/docker/daemon.json 修改配置文件如下:(注意:insecure-registries 是后续要用到的远程镜像仓库地址)
{
"exec-opts": [
"native.cgroupdriver=systemd"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"registry-mirrors": [
"http://hub-mirror.c.163.com",
"https://dockerhub.azk8s.cn"
],
"insecure-registries": [
"*.*.*.*:7000"
]
}
执行 docker version 即可看到如下docker 信息,表示安装正常
[root@k8s-master-67 //]# docker version
Client: Docker Engine - Community
Version: 24.0.5
API version: 1.43
Go version: go1.20.6
Git commit: ced0996
Built: Fri Jul 21 20:39:02 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.5
API version: 1.43 (minimum version 1.12)
Go version: go1.20.6
Git commit: a61e2b4
Built: Fri Jul 21 20:38:05 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
按照上述及可完成docker安装,下一篇 安装 docker-compose,如果安装或者后续干货有问题,请微信扫码交流,或微信号联系:wx215602488