Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
install.api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Script
install.api
Commits
6b9a2be4
Commit
6b9a2be4
authored
Apr 08, 2020
by
金凯强
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除安装包
parent
c62ff4b2
Pipeline
#22203
canceled with stage
in 9 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
134 deletions
+0
-134
docker-19.03.4.tgz
static_file/system_file/docker-19.03.4.tgz
+0
-0
docker-compose-Linux-x86_64
static_file/system_file/docker-compose-Linux-x86_64
+0
-0
install_docker.py
static_file/system_file/install_docker.py
+0
-134
No files found.
static_file/system_file/docker-19.03.4.tgz
deleted
100644 → 0
View file @
c62ff4b2
File deleted
static_file/system_file/docker-compose-Linux-x86_64
deleted
100644 → 0
View file @
c62ff4b2
File deleted
static_file/system_file/install_docker.py
deleted
100644 → 0
View file @
c62ff4b2
# -*- coding:utf-8 -*-
import
os
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'''
def
install_docker
():
'''
安装docker
:return:
'''
print
(
'解压tar包...'
)
res
=
os
.
system
(
'sudo tar -xvf docker-19.03.4.tgz'
)
if
res
==
1
:
raise
RuntimeError
(
'解压tar包失败'
)
print
(
'将docker目录移到/usr/bin目录下...'
)
res
=
os
.
system
(
'sudo cp docker/* /usr/bin/'
)
if
res
==
1
:
raise
RuntimeError
(
'将docker目录移到/usr/bin目录下失败'
)
print
(
'在/etc/systemd/system/目录下创建docekr.service...'
)
with
open
(
'/etc/systemd/system/docker.service'
,
'w'
)
as
f
:
f
.
write
(
docker_service
)
print
(
'添加文件权限...'
)
res
=
os
.
system
(
'sudo chmod +x /etc/systemd/system/docker.service'
)
if
res
==
1
:
raise
RuntimeError
(
'添加文件权限失败'
)
print
(
'新增配置文件/etc/docker/daemon.json...'
)
if
not
os
.
path
.
exists
(
'/etc/docker'
):
os
.
mkdir
(
'/etc/docker'
)
with
open
(
'/etc/docker/daemon.json'
,
'w'
)
as
f
:
f
.
write
(
'''{
"registry-mirrors":["https://m6wlkecl.mirror.aliyuncs.com"],
"insecure-registries": ["http://47.110.145.204:8084","http://183.134.73.2:8084"],
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "3"
}
}'''
)
print
(
'重新加载配置文件...'
)
res
=
os
.
system
(
'sudo systemctl daemon-reload'
)
if
res
==
1
:
raise
RuntimeError
(
'重新加载配置文件失败'
)
print
(
'启动docker...'
)
res
=
os
.
system
(
'sudo systemctl start docker'
)
if
res
==
1
:
raise
RuntimeError
(
'启动docker失败'
)
print
(
'设置开机自启...'
)
res
=
os
.
system
(
'sudo systemctl enable docker.service'
)
if
res
==
1
:
raise
RuntimeError
(
'设置开机自启失败'
)
print
(
'查看docker版本...'
)
res
=
os
.
system
(
'docker -v'
)
if
res
==
1
:
raise
RuntimeError
(
'查看docker版本失败'
)
def
install_docker_compose
():
'''
安装docker_compose
:return:
'''
print
(
'修改/etc/selinux/config下的SELINUX属性'
)
with
open
(
'/etc/selinux/config'
,
'r'
)
as
f
:
config
=
f
.
read
()
config
=
config
.
replace
(
'SELINUX=enforcing'
,
'SELINUX=disabled'
)
with
open
(
'/etc/selinux/config'
,
'w'
)
as
f
:
f
.
write
(
config
)
print
(
'移动文件至/usr/local/bin/docker-compose...'
)
res
=
os
.
system
(
'sudo mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose'
)
if
res
==
1
:
raise
RuntimeError
(
'移动文件至/usr/local/bin/docker-compose失败'
)
print
(
'添加可执行权限...'
)
res
=
os
.
system
(
'sudo chmod +x /usr/local/bin/docker-compose'
)
if
res
==
1
:
raise
RuntimeError
(
'添加可执行权限失败'
)
print
(
'查看docker-compose版本...'
)
res
=
os
.
system
(
'docker-compose -v'
)
if
res
==
1
:
raise
RuntimeError
(
'查看docker-compose版本失败'
)
def
close_firewalld
():
'''
关闭防火墙
:return:syste
'''
print
(
'关闭防火墙...'
)
res
=
os
.
system
(
'''systemctl stop firewalld && systemctl disable firewalld'''
)
if
res
==
1
:
raise
RuntimeError
(
'关闭防火墙失败'
)
if
__name__
==
"__main__"
:
close_firewalld
()
install_docker
()
install_docker_compose
()
os
.
system
(
'mkdir -p /huansi'
)
os
.
system
(
'mkdir -p /huansi/upgrade'
)
print
(
'*****************************************************'
)
print
(
'********服务器需要重启,请输入reboot重启服务器*************'
)
print
(
'*****************************************************'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment