内网环境docker环境搭建
今天接到公司领导要求,搭建一个基于K8S和docker的云底座集群。所以我先尝试搭建了一下docker的环境。1.联网环境搭建docker(1)配置yum源修改/etc/yum.confmain]cachedir=/var/cache/yum/basearch/basearch/basearch/releaseverkeepcache=0debuglevel=2logfile=/v...
今天接到公司领导要求,搭建一个基于K8S和docker的云底座集群。所以我先尝试搭建了一下docker的环境。
1.联网环境搭建docker
(1)配置yum源
修改/etc/yum.conf
main]
cachedir=/var/cache/yum/
b
a
s
e
a
r
c
h
/
basearch/
basearch/releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
[os-repo]
name=os repo
baseurl=http://mirrors.aliyun.com/centos/7/os/
b
a
s
e
a
r
c
h
e
n
a
b
l
e
d
=
1
g
p
g
c
h
e
c
k
=
0
s
k
i
p
i
f
u
n
a
v
a
i
l
a
b
l
e
=
1
[
o
s
−
e
x
t
r
a
s
−
r
e
p
o
]
n
a
m
e
=
o
s
r
e
p
o
e
x
t
r
a
s
b
a
s
e
u
r
l
=
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
c
e
n
t
o
s
/
7
/
e
x
t
r
a
s
/
basearch enabled=1 gpgcheck=0 skip_if_unavailable=1 [os-extras-repo] name=os repo extras baseurl=http://mirrors.aliyun.com/centos/7/extras/
basearchenabled=1gpgcheck=0skipifunavailable=1[os−extras−repo]name=osrepoextrasbaseurl=http://mirrors.aliyun.com/centos/7/extras/basearch
enabled=1
gpgcheck=0
skip_if_unavailable=1
[docker-ce-stable]
name=Docker CE Stable -
b
a
s
e
a
r
c
h
b
a
s
e
u
r
l
=
h
t
t
p
:
/
/
m
i
r
r
o
r
s
.
a
l
i
y
u
n
.
c
o
m
/
d
o
c
k
e
r
−
c
e
/
l
i
n
u
x
/
c
e
n
t
o
s
/
7
/
basearch baseurl=http://mirrors.aliyun.com/docker-ce/linux/centos/7/
basearchbaseurl=http://mirrors.aliyun.com/docker−ce/linux/centos/7/basearch/stable
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/docker-ce/linux/centos/gpg
(2)
yum源cache更新。
yum clean all
yum makecache
(3)安装docker
yum install -y -c /etc/yum.conf docker-ce
2.非联网环境安装docker
1、 虚拟机基础环境:CentOS7.3
2、 下载Docker环境安装包
3、 确定和镜像仓库在同一网段
4、 在/etc/docker/daemon.json中写入:
{
“registry-mirrors”: [“https://registry.docker-cn.com”],
“insecure-registries”:[“207.208.120.222:5000”]
}
注:注意json格式,这里很容易出错
5、 解压压安装包:tar -zxvf docker-18.06.1-ce.tgz
6、 将解压出来的docker文件内容移动到/usr/bin/目录下:cp -rf docker/* /usr/bin/
7、 将docker注册成为service :vim /etc/systemd/system/docker.service
8、 向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
ExecReload=/bin/kill -s HUP $MAINPID
#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
9、 添加文件权限并启动docker:
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
systemctl enable docker.service
10、 查看docker状态
systemctl status docker
docker安装包下载地址https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
更多推荐
所有评论(0)