iis服务器助手广告广告
返回顶部
首页 > 资讯 > 操作系统 >Linux离线环境安装部署docker(超详细)
  • 669
分享到

Linux离线环境安装部署docker(超详细)

dockerlinux容器运维服务器 2023-08-21 05:08:02 669人浏览 八月长安
摘要

离线文件下载:根据实际情况下载离线包 docker-Linux下载地址 搭建Docker环境准备 在能连网的服务器上下载所需的镜像,例如 docker pull Mysql:8(拉取mysql:8镜像)docker images(查看镜像)

离线文件下载:根据实际情况下载离线包

docker-Linux下载地址

搭建Docker环境准备

在能连网的服务器上下载所需的镜像,例如

docker pull Mysql:8(拉取mysql:8镜像)docker images(查看镜像)docker save -o mysql-8.tar mysql:8 (将mysql:8镜像压缩成mysql-8.tar压缩包文件)
上传docker压缩包及镜像上传到需要部署的服务器上,然后进行解压,例如:
  1. 解压docker软件压缩包
tar -zxvf docker-20.10.9.tgz 
  1. 把docker文件里面的内容复制到bin目录下
cp docker/* /usr/bin
  1. 在/etc/systemd/system或者/usr/lib/systemd/system目录下创建文件 docker.Socket和docker.service以及containerd.service

三个文件的内容放最后面,记得先把文件内容加上才能启动docker哦

touch docker.socketouch docker.servicetouch containerd.service
  1. 重新加载配置文件
systemctl daemon-reload 
  1. 创建组
groupadd docker
  1. 启动docker
systemctl start docker
  1. 查看dock是否启动成功:运行命令没报错就没问题了
docker ps 
  1. 设置开机自启动
systemctl enable docker.service
  1. 导入镜像
docker load -i mysql.tar
  1. 查看镜像
docker images
  1. 根据实际情况构建容器,例如:
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWord=123456 mysql:8

docker配置文件内容:

docker.socket

[Unit]Description=Docker Socket for the apiPartOf=docker.service[Socket]ListenStream=/var/run/docker.sockSocketMode=0660SocketUser=rootSocketGroup=docker[Install]WantedBy=sockets.target

docker.service

[Unit]Description=Docker Application Container EngineDocumentation=https://docs.docker.comAfter=network.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#ExecStart=/usr/bin/docker daemon --tlsverify --tlscacert=/root/openssl/ca.pem --tlscert=/root/openssl/server-cert.pem --tlskey=/root/openssl/server-key.pem --reGIStry-mirror=Http://3cda3ca9.m.daocloud.io -H tcp://0.0.0.0:2376#ExecStart=/usr/bin/docker daemon --registry-mirror=http://3cda3ca9.m.daocloud.io -H fd:// -H tcp://0.0.0.0:2375#ExecStart=/usr/bin/dockerd --registry-mirror=http://3cda3ca9.m.daocloud.ioExecStart=/usr/bin/dockerd --registry-mirror=http://3cda3ca9.m.daocloud.io -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375ExecReload=/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=infinityLimitNPROC=infinityLimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process[Install]WantedBy=multi-user.target

containerd.service

# Copyright The containerd Authors.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at##     http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language Governing permissions and# limitations under the License.[Unit]Description=containerd container runtimeDocumentation=https://containerd.ioAfter=network.target local-fs.target[Service]ExecStartPre=-/sbin/modprobe overlayExecStart=/usr/local/bin/containerdType=notifyDelegate=yesKillMode=processRestart=alwaysRestartSec=5# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNPROC=infinityLimitCORE=infinityLimitNOFILE=infinity# Comment TasksMax if your systemd version does not supports it.# Only systemd 226 and above support this version.TasksMax=infinityOOMScoreAdjust=-999[Install]WantedBy=multi-user.target

来源地址:https://blog.csdn.net/qq_62242833/article/details/128205117

--结束END--

本文标题: Linux离线环境安装部署docker(超详细)

本文链接: https://www.lsjlt.com/news/376728.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作