华为鲲鹏麒麟安装docker

安装docker-ce

下载二进制docker

arm:官方下载地址:https://download.docker.com/linux/static/stable/aarch64/

x86:官方下载地址:  https://download.docker.com/linux/static/stable/x86_64/

登录服务器下载相应的软件包

wget https://download.docker.com/linux/static/stable/aarch64/docker-20.10.9.tgz

wget https://download.docker.com/linux/static/stable/x86_64/docker-23.0.6.tgz

解压下载好的压缩包

[root@ecs-arm-ky-001 ~]# tar -zxvf docker-20.10.9.tgz

移动解压出来的二进制文件到/usr/bin目录中

[root@ecs-arm-ky-001 ~]# mv docker/* /usr/bin/

测试docker

[root@ecs-arm-ky-001 ~]# dockerd

 

添加systemd

添加docker的systemd服务脚本到  /usr/lib/systemd/system/

脚本参考自 https://github.com/docker/docker-ce

# 使用这个才能启动成功
cat > /usr/lib/systemd/system/docker.service <<'EOF'
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash

ExecStart=/usr/bin/dockerd $OPTIONS \
                           $DOCKER_STORAGE_OPTIONS \
                           $DOCKER_NETWORK_OPTIONS \
                           $INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target
EOF
#============================================
cat > /etc/sysconfig/docker <<'EOF'
# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--live-restore'

DOCKER_CERT_PATH=/etc/docker

# If you have a registry secured with https but do not have proper certs
# distributed, you can tell docker to not look for full authorization by
# adding the registry to the INSECURE_REGISTRY line and uncommenting it.
# INSECURE_REGISTRY='--insecure-registry'

# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overridden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp
EOF
#========================================================

cat > /etc/sysconfig/docker-storage <<'EOF'
# This file may be automatically generated by an installation program.

# By default, Docker uses a loopback-mounted sparse file in
# /var/lib/docker.  The loopback makes it slower, and there are some
# restrictive defaults, such as 100GB max storage.

# If your installation did not set a custom storage for Docker, you
# may do it below.

# Example: Use a custom pair of raw logical volumes (one for metadata,
# one for data).
# DOCKER_STORAGE_OPTIONS = --storage-opt dm.metadatadev=/dev/mylogvol/my-docker-metadata --storage-opt dm.datadev=/dev/mylogvol/my-docker-data

DOCKER_STORAGE_OPTIONS=
EOF
#======================================================

cat > /etc/sysconfig/docker-network <<'EOF'
# /etc/sysconfig/docker-network
DOCKER_NETWORK_OPTIONS=
EOF

 

重载systemd配置文件

[root@ecs-arm-ky-001 ~]# systemctl daemon-reload

创建docker组

groupadd docker

如不创建 docker 组在通过 systemctl 启动时会报错如下

Dependency failed for Docker Application Container Engine.
Job docker.service/start failed with result 'dependency'.

启动 docker 服务

[root@ecs-arm-ky-001 ~]# systemctl start docker
[root@ecs-arm-ky-001 ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

修改 docker 配置文件并查看安装好的 docker 基本信息,增加docker镜像加速

mkdir -p /etc/docker/
cat > /etc/docker/daemon.json <<'EOF'
{
  "registry-mirrors": ["https://s7p0cq94.mirror.aliyuncs.com"]
}
EOF

重启 docker 服务

systemctl restart docker

查看 docker info

docker info

 

posted @ 2022-03-25 22:37  丶蜡笔小兴  阅读(960)  评论(0编辑  收藏  举报