Docker安装的yum安装方式和二进制安装方式,并且配置docker镜像加速

1.基于centos 7,修改yum源安装

[root@bbs ~]# wget -O /etc/yum.repos.d/docker.repo  https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo --no-check-certificate
[root@bbs ~]# yum list docker-ce.x86_64  --showduplicates | sort -r
[root@bbs ~]# vim /etc/yum.repos.d/docker.repo 
          :% s#download.docker.com#mirrors.tuna.tsinghua.edu.cn/docker-ce#g
          #然后wq保存退出
#上面一行是进入编辑模式后,
#把里面安装包的来源由docker官网的源替换成清华大学镜像站的源,这样安装东西起来很快速简单
[root@bbs ~]# yum clean all
[root@bbs ~]# yum install docker-ce
#这里安装的直接就是最新版,如果想安装某个版本,可以根据yum list docker-ce.x86_64  --showduplicates | sort -r,筛选出合适自己的版本选择安装
[root@bbs ~]# docker -v
Docker version 20.10.17, build 100c701
[root@bbs ~]# systemctl enable docker --now
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

2.二进制安装
首先,先下载软件包,然后进行解压到指定目录,创建软链接

[root@localhost ~]# wget -c https://download.docker.com/linux/static/stable/x86_64/docker-20.10.17.tgz
[root@localhost ~]# ll
-rw-r--r--. 1 root root 64988857 Jun  6 17:56 docker-20.10.17.tgz
[root@localhost ~]# tar xf docker-20.10.17.tgz -C /usr/local
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root   root     6 Apr 10  2018 bin
drwxrwxr-x. 2 redhat redhat 169 Jun  6 16:03 docker
drwxr-xr-x. 2 root   root     6 Apr 10  2018 etc
drwxr-xr-x. 2 root   root     6 Apr 10  2018 games
drwxr-xr-x. 2 root   root     6 Apr 10  2018 include
drwxr-xr-x. 2 root   root     6 Apr 10  2018 lib
drwxr-xr-x. 2 root   root     6 Apr 10  2018 lib64
drwxr-xr-x. 2 root   root     6 Apr 10  2018 libexec
drwxr-xr-x. 2 root   root     6 Apr 10  2018 sbin
drwxr-xr-x. 5 root   root    49 Mar 26 06:01 share
drwxr-xr-x. 2 root   root     6 Apr 10  2018 src
[root@localhost local]# cd docker/
[root@localhost docker]# ll
total 204048
-rwxr-xr-x. 1 redhat redhat 39838504 Jun  6 16:03 containerd
-rwxr-xr-x. 1 redhat redhat  7585792 Jun  6 16:03 containerd-shim
-rwxr-xr-x. 1 redhat redhat  9859072 Jun  6 16:03 containerd-shim-runc-v2
-rwxr-xr-x. 1 redhat redhat 23834624 Jun  6 16:03 ctr
-rwxr-xr-x. 1 redhat redhat 50511896 Jun  6 16:03 docker
-rwxr-xr-x. 1 redhat redhat 60261480 Jun  6 16:03 dockerd
-rwxr-xr-x. 1 redhat redhat   704520 Jun  6 16:03 docker-init
-rwxr-xr-x. 1 redhat redhat  2559454 Jun  6 16:03 docker-proxy
-rwxr-xr-x. 1 redhat redhat 13774272 Jun  6 16:03 runc
[root@localhost docker]# ln -sv /usr/local/docker/* /usr/bin/
#这里创建软链接主要是因为docker、contained、runc
#这里可以知道docker是客户端要使用的命令,所以需要创建软链接,而且容器也是使用docker来启动的
‘/usr/bin/containerd’ -> ‘/usr/local/docker/containerd’
‘/usr/bin/containerd-shim’ -> ‘/usr/local/docker/containerd-shim’
‘/usr/bin/containerd-shim-runc-v2’ -> ‘/usr/local/docker/containerd-shim-runc-v2’
‘/usr/bin/ctr’ -> ‘/usr/local/docker/ctr’
‘/usr/bin/docker’ -> ‘/usr/local/docker/docker’
‘/usr/bin/dockerd’ -> ‘/usr/local/docker/dockerd’
‘/usr/bin/docker-init’ -> ‘/usr/local/docker/docker-init’
‘/usr/bin/docker-proxy’ -> ‘/usr/local/docker/docker-proxy’
‘/usr/bin/runc’ -> ‘/usr/local/docker/runc’

然后,配置docker的服务脚本,这下面是属于官方的配置文件,可用

[root@localhost system]# vim /usr/lib/systemd/system/docker.service 

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=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
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

[root@localhost system]# vim /usr/lib/systemd/system/docker.socket 

[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target


[root@localhost system]# vim /usr/lib/systemd/system/containerd.service 

# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd

Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target
[root@localhost system]# vim /usr/lib/systemd/system/container-getty@.service 

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Container Getty on /dev/pts/%I
Documentation=man:agetty(8) man:machinectl(1)
After=systemd-user-sessions.service plymouth-quit-wait.service
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Container Getty on /dev/pts/%I
Documentation=man:agetty(8) man:machinectl(1)
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service getty-pre.target
Before=getty.target
IgnoreOnIsolate=yes
ConditionPathExists=/dev/pts/%I

[Service]
ExecStart=-/sbin/agetty --noclear --keep-baud pts/%I 115200,38400,9600 $TERM
Type=idle
Restart=always
RestartSec=0
UtmpIdentifier=pts/%I
TTYPath=/dev/pts/%I
TTYReset=yes
TTYVHangup=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
[root@localhost system]# groupadd -r docker
[root@localhost system]# systemctl enable --now docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

然后,创建docker组,启动服务,这样docker的二进制安装方式就配置好了。

下面进行配置docker的镜像加速

打开阿里云,控制台搜索镜像,点击容器服务列表的容器镜像服务,打开之后,点击镜像加速器,然后可以照着配置就行

[root@localhost system]# mkdir /etc/docker
[root@localhost system]# tee /etc/docker/daemon.json <<-'EOF'
 {
  "registry-mirrors": ["https://0zkmck3p.mirror.aliyuncs.com"]
}
> EOF
[root@localhost system]# systemctl daemon-reload
[root@localhost system]# systemctl restart docker

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
从Kolla的版本“Victoria”开始,使用二进制镜像安装Kolla的步骤如下: 1. 首先安装Kolla依赖的软件包。这些软件包包括Docker等工具,可以使用以下命令在CentOS和Ubuntu上安装: CentOS: ``` sudo yum install -y docker-ce python3-pip ``` Ubuntu: ``` sudo apt-get update sudo apt-get install -y docker-ce python3-pip ``` 2. 安装Kolla。可以使用以下命令安装最新版本的Kolla: ``` sudo pip3 install kolla ``` 3. 为Kolla生成配置文件。可以使用以下命令生成默认配置文件: ``` sudo kolla-ansible genconfig ``` 4. 配置Ansible inventory。需要为Kolla配置一个Ansible inventory文件,指定要在哪些节点上部署Kolla。可以使用以下命令生成样例inventory文件: ``` sudo kolla-ansible inventory-gen ``` 5. 配置二进制镜像源。需要在Kolla配置文件中指定要使用的镜像源,可以使用以下命令编辑配置文件: ``` sudo vi /etc/kolla/kolla-build.conf ``` 在文件中找到`[DEFAULT]`部分,将`base`和`type_images`选项设置为您要使用的镜像源。例如: ``` [DEFAULT] base = registry.cn-hangzhou.aliyuncs.com/kolla type_images = registry.cn-hangzhou.aliyuncs.com/kolla ``` 6. 构建二进制镜像。可以使用以下命令在所有节点上构建二进制镜像: ``` sudo kolla-ansible -i /etc/kolla/inventory bootstrap-servers ``` 7. 部署Kolla。可以使用以下命令在所有节点上部署Kolla: ``` sudo kolla-ansible deploy ``` 这些步骤可以帮助您使用二进制镜像安装Kolla。请注意,这只是一个简单的指南,您可能需要根据您的环境进行一些自定义配置

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值