背景
总结下docker的一些知识
docker安装(有网络版)
参考文章我以前试过这个帖子,建议安装高版本的docker,(20以上的,不然可能会有一些问题)文章来源:https://www.toymoban.com/news/detail-833765.html
## 1、安装依赖
[root@iZo7e61fz42ik0Z ~]#yum install -y yum-utils device-mapper-persistent-data lvm2
## 2、添加docker软件源
[root@iZo7e61fz42ik0Z ~]#yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## 3、只保留稳定版本
[root@iZo7e61fz42ik0Z ~]#yum-config-manager --disable docker-ce-edge
[root@iZo7e61fz42ik0Z ~]#yum-config-manager --disable docker-ce-test
## 4、更新包索引
[root@iZo7e61fz42ik0Z ~]#yum makecache fast
## 5、更新yum包索引
[root@iZo7e61fz42ik0Z ~]#yum list docker-ce --showduplicates|sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 @docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
Available Packages
# 安装指定版本
[root@iZo7e61fz42ik0Z ~]#yum -y install docker-ce-18.06.1.ce
Docker安装完毕,启动Docker服务查看一下版本文章来源地址https://www.toymoban.com/news/detail-833765.html
# 启动docker
[root@iZo7e61fz42ik0Z ~]#systemctl start docker
# 开机自启
[root@iZo7e61fz42ik0Z ~]#systemctl enable docker
# 查看版本
[root@iZo7e61fz42ik0Z ~]# docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:03 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:25:29 2018
OS/Arch: linux/amd64
Experimental: false
docker安装(无网络版)
- 提前下载docker,下载docker的安装文件:https://download.docker.com/linux/static/stable/x86_64/
- 开始安装
docker 安装,这里我下载的19.03.9,后续就出现了一些端口安全的问题
# 解压docker 安装包
tar -zxvf docker-19.03.9.tgz
# 解压文件移动到到 /usr/bin
mv docker/* /usr/bin/
# 配置docker.service 文件
cd /etc/systemd/system/
# 把离线部署里的docker.service文件传到这个目录
可以使用sftp,或者rz命令
# 赋予执行权限
chmod +x /etc/systemd/system/docker.service
# 重新加载配置文件
systemctl daemon-reload
# 开机自启
systemctl enable docker.service
# 启动docker
systemctl start docker
#查看docker版本
docker -v
- docker.service文件
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[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 tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP
# 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
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# 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
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
到了这里,关于centos7下docker的安装的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!