【docker学习】Linux系统离线方式安装docker环境方法

centos7-linux安装docker(离线方式)

下载docker的安装文件

https://download.docker.com/linux/static/stable/x86_64/

下载的是:docker-18.06.3-ce.tgz 这个压缩文件

将docker-18.06.3-ce.tgz文件上传到centos7-linux系统上,用ftp工具上传即可

解压

powershell 复制代码
[root@localhost java]# tar -zxvf docker-18.06.3-ce.tgz

将解压出来的docker文件复制到 /usr/bin/ 目录下

powershell 复制代码
[root@localhost java]# cp docker/* /usr/bin/

进入/etc/systemd/system/目录,并创建docker.service文件

powershell 复制代码
[root@localhost java]# cd /etc/systemd/system/
[root@localhost system]# touch docker.service

打开docker.service文件,将以下内容复制

powershell 复制代码
[root@localhost system]# vi docker.service

注意: --insecure-registry=192.168.200.xxx 此处改为你自己服务器ip

bash 复制代码
[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 --selinux-enabled=false --insecure-registry=192.168.200.xxx
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

给docker.service文件添加执行权限

powershell 复制代码
[root@localhost system]# chmod 777 /etc/systemd/system/docker.service 

重新加载配置文件(每次有修改docker.service文件时都要重新加载下)

powershell 复制代码
[root@localhost system]# systemctl daemon-reload 

启动

powershell 复制代码
[root@localhost system]# systemctl start docker

设置开机启动

powershell 复制代码
[root@localhost system]# systemctl enable docker.service

查看docker状态

powershell 复制代码
[root@localhost system]# systemctl status docker

出现下面这个界面就代表docker安装成功。

配置镜像加速器,默认是到国外拉取镜像速度慢,可以配置国内的镜像如:阿里、网易等等。下面配置一下网易的镜像加速器。打开docker的配置文件: /etc/docker/daemon.json文件:

powershell 复制代码
[root@localhost docker]# vi /etc/docker/daemon.json

配置如下:

bash 复制代码
{"registry-mirrors": ["http://hub-mirror.c.163.com"]}

配置完后:wq保存配置并重启docker 一定要重启不然加速是不会生效的!!!

powershell 复制代码
[root@localhost docker]# service docker restart

参考:https://www.cnblogs.com/kingsonfu/p/11576797.html

相关推荐
极客先躯24 分钟前
高级java每日一道面试题-2026年04月05日-实战篇[Docker]-如何排查容器 OOM 的问题?
java·运维·docker·容器·内存溢出·高级面试
带娃的IT创业者26 分钟前
监控并非安全:当隐私成为技术的祭品
java·开发语言·安全·数据安全·监控·隐私保护·加密技术
非鱼䲆鱻䲜1 小时前
CCS 20.5.0的printf重定向串口怎么实现?
linux·单片机·电赛·ccs
左手厨刀右手茼蒿1 小时前
PCIe设备驱动开发:从枚举到DMA传输的完整链路
linux·嵌入式·系统内核
济6171 小时前
I.MX6U Linux 驱动开发篇---零基础必看!中断实验(按键中断 + 定时器消抖 + 设备树配置实战教程)--- Ubuntu20.04
linux·驱动开发·嵌入式·嵌入式linux驱动开发
叩码以求索1 小时前
使用next数组加速匹配过程
java·数据结构·算法
~kiss~1 小时前
LLM 的 层归一化(稳定训练) - Layer Normalization & RMSNorm
学习
seven_stars_1 小时前
CVE-2018-19518PHP漏洞
linux·浏览器·kali
余额瞒着我当琳1 小时前
C++ 基础核心概念精讲:引用、内联与 nullptr
java·开发语言·c++