ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

docker离线和在线安装

2026/8/8 18:50:57 拓冰建站 浏览量
docker离线和在线安装 一.docker环境1.在线安装###########centos在线安装############# #1.更新yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo yum clean all yum makecache #2.添加docker国内镜像源 yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #3.安装docker yum -y install docker-ce docker-ce-cli containerd.io ##########ubuntu在线安装######### apt install -y docker.io2.离线安装#1.自己准备docker离线包本文自带 dockerBin.zip #2.解压移动文件 unzip dockerBin.zip cp ./docker/* /usr/bin/ #启动程序 cp ./docker/docker.service /etc/systemd/system #开机自启文件末尾有第4小节 #3.启动docker、开机自启、查看docker启动状态 systemctl daemon-reload #重新加载systemctl文件 systemctl start docker systemctl enable docker systemctl status docker #4.docker.service文件如下 cat docker.service [Unit] DescriptionDocker Application Container Engine Documentationhttps://docs.docker.com # BindsTocontainerd.service Afternetwork-online.target firewalld.service # containerd.service Wantsnetwork-online.target # Requiresdocker.socket [Service] Typenotify # 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 EnvironmentFile-/etc/sysconfig/docker EnvironmentFile-/etc/sysconfig/docker-storage EnvironmentFile-/etc/sysconfig/docker-network EnvironmentGOTRACEBACKcrash ExecStart/usr/bin/dockerd $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $INSECURE_REGISTRY # -H fd:// --containerd/run/containerd/containerd.sock ExecReload/bin/kill -s HUP $MAINPID TimeoutSec0 RestartSec2 Restartalways # Note that StartLimit* options were moved from Service to Unit in systemd 229. # Both the old, and new location are accepted by systemd 229 and up, so using the old location # to make them work for either version of systemd. StartLimitBurst3 # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make # this option work for either version of systemd. StartLimitInterval60s # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILEinfinity LimitNPROCinfinity LimitCOREinfinity # Comment TasksMax if your systemd version does not support it. # Only systemd 226 and above support this option. TasksMaxinfinity # set delegate yes so that systemd does not reset the cgroups of docker containers Delegateyes # kill only the docker process, not all processes in the cgroup KillModeprocess [Install] WantedBymulti-user.target3.docker镜像加速配置#编写/etc/docker/daemon.json配置文件 #1.基础版本完全够用 tee /etc/docker/daemon.json -EOF { registry-mirrors: [https://ej3odski.mirror.aliyuncs.com] } EOF #2.不理解不要配 tee /etc/docker/daemon.json -EOF { log-driver: json-file, log-opts: { max-size: 100m, max-file: 3 }, exec-opts: [native.cgroupdriversystemd], storage-driver: overlay2, storage-opts: [ overlay2.override_kernel_checktrue ], registry-mirrors: [ https://docker.mirrors.ustc.edu.cn, https://hub-mirror.c.163.com ] } EOF #注意配置文件更新后需要重启docker systemctl restart docker