Linux Redhat 7 下 Docker 离线安装部署
Docker安装前要
Docker官网:
服务器版:https://docs.docker.com/engine/install/#server
Docker 离线二进制tgz压缩包下载地址:
https://download.docker.com/linux/static/stable/x86_64/
例如:
docker-23.0.6.tgz
Docker 离线rpm包下载地址:
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
Docker安装步骤
- 确定OS系统环境,CentOS 7/Redhat 7及以上版本
[root@test soft]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.9 (Maipo) [root@test soft]# uname -a Linux test 3.10.0-1160.el7.x86_64 #1 SMP Tue Aug 18 14:50:17 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux [root@test soft]# |
2、卸载旧版本
[root@test soft]# ps -ef|grep docker root 3866 3625 0 09:12 pts/0 00:00:00 grep --color=auto docker [root@test soft]# [root@test soft]# yum remove docker \ > docker-client \ > docker-client-latest \ > docker-common \ > docker-latest \ > docker-latest-logrotate \ > docker-logrotate \ > docker-engine Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. No Match for argument: docker No Match for argument: docker-client No Match for argument: docker-client-latest No Match for argument: docker-common No Match for argument: docker-latest No Match for argument: docker-latest-logrotate No Match for argument: docker-logrotate No Match for argument: docker-engine No Packages marked for removal [root@test soft]# |
- 下载离线安装包,上传至服务端并解压
[root@test soft]# tar -zxvf docker-23.0.6.tgz docker/ docker/docker-proxy docker/containerd-shim-runc-v2 docker/ctr docker/docker docker/docker-init docker/runc docker/dockerd docker/containerd [root@test soft]# |
- 将解压后得到的二进制文件全复制到/usr/bin目录下
[root@test soft]# cp docker/* /usr/bin/ |
5、将docker注册成系统服务,修改" vi /etc/systemd/system/docker.service " 内容(没有的话vi命令会自动创建该文件);
注意:配置需要注意的是 : ExecStart=/usr/bin/dockerd,代表dockerd所在位置
[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 |
- 增加文件可执行权限
chmod +x /etc/systemd/system/docker.service systemctl daemon-reload |
- 设置开机自启动
systemctl enable docker.service systemctl status docker.service ##systemctl disable docker.service |
- 启动docker
systemctl start docker ##systemctl stop docker |
- 测试
docker ps |
如果打印出如下信息,则表示正确安装:
[root@test soft]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@test soft]#
标签:Redhat,No,soft,离线,Linux,test,docker,root,Docker From: https://www.cnblogs.com/fukeyiyang/p/17896070.html