Docker-ce安装
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">前面已介绍了docker的<span style="color: black;">有些</span>知识,今天就来带<span style="color: black;">大众</span>安装docker 社区版本。<span style="color: black;">倘若</span>安装过程中碰到问题,随时留言<span style="color: black;">博主</span>。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/87fb24d5a063412080528ad4b58adc57~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728823933&x-signature=HSm4p2iLZJdvKRMOkSVnjN7SveA%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1、Debian/Ubuntu系统</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">以下内容<span style="color: black;">按照</span> 官方文档 修改而来。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.1 <span style="color: black;">倘若</span>你过去安装过 docker,先删掉:</p>sudo apt-<span style="color: black;">get</span> <span style="color: black;">remove</span>docker docker-engine docker.io containerd runc<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.2 <span style="color: black;">首要</span>安装依赖:</p>sudo apt-<span style="color: black;">get</span> install apt-transport-https ca-certificates curl gnupg2 software-properties-common<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.3 信任 Docker 的 GPG 公钥:</p><span style="color: black;">curl</span> -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.4 添加软件仓库,最好是国内的源<span style="color: black;">位置</span>,<span style="color: black;">这儿</span>以清华源为例</p><span style="color: black;">echo</span> \
<span style="color: black;">"deb https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable"</span> | sudo tee /etc/apt/sources.<span style="color: black;">list</span>.d/docker.<span style="color: black;">list</span> > /dev/<span style="color: black;">null</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1.5 最后安装</p>sudo apt-get <span style="color: black;">update</span>
sudo apt-<span style="color: black;">get</span> <span style="color: black;">install</span> docker-ce<h1 style="color: black; text-align: left; margin-bottom: 10px;">2、Fedora/CentOS/RHEL系统</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">以下内容<span style="color: black;">按照</span> 官方文档 修改而来。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.1 <span style="color: black;">倘若</span>你之前安装过 docker,请先删掉</p>sudo yum <span style="color: black;">remove</span>docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.2 安装<span style="color: black;">有些</span>依赖</p>sudo yum <span style="color: black;">install</span> -y yum-utils device-mapper-persistent-<span style="color: black;">data</span> lvm2<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.3 安装repo</p>yum-config-manager --<span style="color: black;">add</span>-repo https:<span style="color: black;">//download.docker.com/linux/centos/docker-ce.repo</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.4 把软件仓库<span style="color: black;">位置</span>替换国内的源,如清华源、阿里源等</p><span style="color: black;">sudo</span> sed -i <span style="color: black;">s+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+</span> /etc/yum.repos.d/docker-ce.repo<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2.5 最后安装</p><span style="color: black;">sudo</span> <span style="color: black;">yum makecache fast</span>
<span style="color: black;">sudo</span> <span style="color: black;">yum install docker-ce</span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">3、验证 docker 信息:</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.1 docker info 查看安装信息</p><span style="color: black;">root@docker-server1:~#</span> <span style="color: black;">docker</span> <span style="color: black;">info</span>
<span style="color: black;">Containers:</span> <span style="color: black;">2</span> <span style="color: black;">#当前主机运行的容器总数</span>
<span style="color: black;">Running:</span> <span style="color: black;">1</span> <span style="color: black;">#有几个容器是正在运行的</span>
<span style="color: black;">Paused:</span> <span style="color: black;">0</span> <span style="color: black;">#有几个容器是暂停的</span>
<span style="color: black;">Stopped:</span> <span style="color: black;">1</span>
<span style="color: black;">Images:</span> <span style="color: black;">3</span> <span style="color: black;">#当前服务器的镜像数</span>
<span style="color: black;">Server Version:</span> <span style="color: black;">18.09</span><span style="color: black;">.9</span> <span style="color: black;">#服务端版本</span>
<span style="color: black;">Storage Driver:</span> <span style="color: black;">overlay2</span> <span style="color: black;">#正在<span style="color: black;">运用</span>的存储引擎</span>
<span style="color: black;">Backing Filesystem:</span> <span style="color: black;">xfs</span> <span style="color: black;">#后端文件系统,即服务器的磁盘文件系统</span>
<span style="color: black;">Supports d_type:</span> <span style="color: black;">true</span> <span style="color: black;">#<span style="color: black;">是不是</span>支持 d_type</span>
<span style="color: black;">Native Overlay Diff:</span> <span style="color: black;">true</span> <span style="color: black;">#<span style="color: black;">是不是</span>支持差异数据存储</span>
<span style="color: black;">Logging Driver:</span> <span style="color: black;">json-file</span> <span style="color: black;">#日志类型</span>
<span style="color: black;">Cgroup Driver:</span> <span style="color: black;">cgroupfs</span> <span style="color: black;">#Cgroups 类型</span>
<span style="color: black;">Plugins:</span> <span style="color: black;">#插件</span>
<span style="color: black;">Volume:</span> <span style="color: black;">local</span> <span style="color: black;">#卷</span>
<span style="color: black;">Network:</span> <span style="color: black;">bridge</span> <span style="color: black;">host</span> <span style="color: black;">macvlan</span> <span style="color: black;">null</span> <span style="color: black;">overlay</span> <span style="color: black;"># overlay 夸主机通信</span>
<span style="color: black;">Log:</span> <span style="color: black;">awslogs</span> <span style="color: black;">fluentd</span> <span style="color: black;">gcplogs</span> <span style="color: black;">gelf</span> <span style="color: black;">journald</span> <span style="color: black;">json-file</span> <span style="color: black;">local</span> <span style="color: black;">logentries</span> <span style="color: black;">splunk</span>
<span style="color: black;">syslog</span> <span style="color: black;">#日志类型</span>
<span style="color: black;">Swarm:</span> <span style="color: black;">inactive</span> <span style="color: black;">#<span style="color: black;">是不是</span>支持 swarm</span>
<span style="color: black;">Runtimes:</span> <span style="color: black;">runc</span> <span style="color: black;">#已安装的容器运行时</span>
<span style="color: black;">Default Runtime:</span> <span style="color: black;">runc</span> <span style="color: black;">#默认<span style="color: black;">运用</span>的容器运行时</span>
<span style="color: black;">Init Binary:</span> <span style="color: black;">docker-init</span> <span style="color: black;">#初始化容器的<span style="color: black;">保护</span>进程,即 pid 为 1 的进程</span>
<span style="color: black;">containerd version:</span> <span style="color: black;">894b81a4b802e4eb2a91d1ce216b8817763c29fb</span> <span style="color: black;">#版本</span>
<span style="color: black;">runc version:</span> <span style="color: black;">425e105d5a03fabd737a126ad93d62a9eeede87f</span> <span style="color: black;"># runc 版本</span>
<span style="color: black;">init version:</span> <span style="color: black;">fec3683</span> <span style="color: black;">#init 版本</span>
<span style="color: black;">Security Options:</span> <span style="color: black;">#安全选项</span>
<span style="color: black;">Apparmor</span> <span style="color: black;">#安全模块, https://docs.docker.com/engine/security/apparmor/</span>
<span style="color: black;">seccomp</span> <span style="color: black;">#审计(操作),https://docs.docker.com/engine/security/seccomp/</span>
<span style="color: black;">Profile:</span> <span style="color: black;">default</span> <span style="color: black;">#默认的配置文件</span>
<span style="color: black;">Kernel Version:</span> <span style="color: black;">4.15</span><span style="color: black;">.0</span><span style="color: black;">-55</span><span style="color: black;">-generic</span> <span style="color: black;">#宿主机内核版本</span>
<span style="color: black;">Operating System:</span> <span style="color: black;">Ubuntu</span> <span style="color: black;">18.04</span><span style="color: black;">.3</span> <span style="color: black;">LTS</span> <span style="color: black;">#宿主机操作系统</span>
<span style="color: black;">OSType:</span> <span style="color: black;">linux</span> <span style="color: black;">#宿主机操作系统类型</span>
<span style="color: black;">Architecture:</span> <span style="color: black;">x86_64</span> <span style="color: black;">#宿主机架构</span>
<span style="color: black;">CPUs:</span> <span style="color: black;">1</span> <span style="color: black;">#宿主机 CPU 数量</span>
<span style="color: black;">Total Memory:</span> <span style="color: black;">1.</span><span style="color: black;">924GiB</span> <span style="color: black;">#宿主机总内存</span>
<span style="color: black;">Name:</span> <span style="color: black;">docker-server1.magedu.net</span> <span style="color: black;">#宿主机 hostname</span>
<span style="color: black;">ID:</span>
<span style="color: black;">ZFPD:UIA5:SR6E:Y6SS:52QL:5MPT:VDY3:ATVI:QMVG:HAFF:MN74:2HPD</span> <span style="color: black;">#</span>
<span style="color: black;">宿主机</span> <span style="color: black;">ID</span>
<span style="color: black;">Docker Root Dir:</span> <span style="color: black;">/var/lib/docker</span> <span style="color: black;">#宿主机数据<span style="color: black;">保留</span>目录</span>
<span style="color: black;">Debug</span> <span style="color: black;">Mode</span> <span style="color: black;">(client):</span> <span style="color: black;">false</span> <span style="color: black;">#client 端<span style="color: black;">是不是</span>开启 debug</span>
<span style="color: black;">Debug</span> <span style="color: black;">Mode</span> <span style="color: black;">(server):</span> <span style="color: black;">false</span> <span style="color: black;">#server 端<span style="color: black;">是不是</span>开启 debug</span>
<span style="color: black;">Registry:</span> <span style="color: black;">https://index.docker.io/v1/</span> <span style="color: black;">#镜像仓库</span>
<span style="color: black;">Labels:</span> <span style="color: black;">#其他标签</span>
<span style="color: black;">Experimental:</span> <span style="color: black;">false</span> <span style="color: black;">#<span style="color: black;">是不是</span>测试版</span>
<span style="color: black;">Insecure Registries:</span> <span style="color: black;">#非安全的镜像仓库</span>
<span style="color: black;">127.0</span><span style="color: black;">.0</span><span style="color: black;">.0</span><span style="color: black;">/8</span>
<span style="color: black;">Live Restore Enabled:</span> <span style="color: black;">false</span> <span style="color: black;">#<span style="color: black;">是不是</span>开启活动重启(重启 docker-daemon 不关闭容</span>
<span style="color: black;">器)</span>
<span style="color: black;">Product License:</span> <span style="color: black;">Community</span> <span style="color: black;">Engine</span> <span style="color: black;">#<span style="color: black;">制品</span>许可信息</span>
<span style="color: black;">WARNING:</span> <span style="color: black;">No</span> <span style="color: black;">swap</span> <span style="color: black;">limit</span> <span style="color: black;">support</span> <span style="color: black;">#系统警告信息(<span style="color: black;">无</span>开启 swap 资源限制)</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.2 <span style="color: black;">处理</span>ubuntu中部分版本不支持 swap 限制警告:</p><span style="color: black;">root@docker-server1:~# vim /etc/default/grub</span>GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=<span style="color: black;">""</span>
GRUB_CMDLINE_LINUX=<span style="color: black;">"net.ifnames=0 biosdevname=0 cgroup_enable=memory swapaccount=1"</span>
<span style="color: black;"># update-grub</span>
<span style="color: black;"># reboot</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3.3 配置加速,<span style="color: black;">这儿</span>添加的是阿里云加速<span style="color: black;">位置</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>不<span style="color: black;">晓得</span>怎么<span style="color: black;">查询</span>阿里云加速<span style="color: black;">位置</span>,请在评论留下你的评论。<span style="color: black;">博主</span>会在<span style="color: black;">第1</span>时间回复你。</p>~]<span style="color: black;"># vim /etc/docker/daemon.json # 初始化配置</span>
{
<span style="color: black;">"graph"</span>:<span style="color: black;">"/data/docker"</span>,
<span style="color: black;">"storage-driver"</span>:<span style="color: black;">"overlay2"</span>,
<span style="color: black;">"insecure-registries"</span>:[<span style="color: black;">"registry.access.redhat.com"</span>,<span style="color: black;">"quay.io"</span>,<span style="color: black;">"harbor.host.com"</span>],<span style="color: black;">#第三个<span style="color: black;">位置</span>为自己本地的仓库域名</span>
<span style="color: black;">"registry-mirrors"</span>:[<span style="color: black;">"https://xxxxxxx.mirror.aliyuncs.com"</span>],<span style="color: black;">#加速<span style="color: black;">位置</span></span>
<span style="color: black;">"exec-opts"</span>:[<span style="color: black;">"native.cgroupdriver=systemd"</span>],
<span style="color: black;">"log-opts"</span>:{<span style="color: black;">"max-size"</span>:<span style="color: black;">"32M"</span>, <span style="color: black;">"max-file"</span>:<span style="color: black;">"2"</span>},
<span style="color: black;">"live-restore"</span>:<span style="color: black;">true</span>
}
你的见解真是独到,让我受益良多。 外贸B2B平台有哪些?
页:
[1]