工作原因需要在客户现场离线安装docker,网上看了很多,官方文档也查了一下,总结如下:
(已在客户现场成功安装,Centos7,其他linux版本没试过,感觉应该问题不大)
1. 下载离线安装包
提前找一台能上网的机器下载好离线安装包
地址:https://download.docker.com/linux/static/stable/
选择合适自己的版本。我这里用的是x86-64/docker-18.03.1-ce.tgz
2. 安装
安装包上传至服务器,解压缩:
tar -zxvf docker-18.03.1-ce.tgz
解压缩后的文件拷贝到对应目录:
cp docker/* /usr/bin/
3.注册docker服务
新建一个文件vi 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
将docker.service 拷贝到对应目录下:
cp docker.service /usr/lib/systemd/system/
4.启动和验证
启动docker服务:
systemctl start docker
验证是否成功:
##这里就比较随意,用一些常用的docker命令
docker -v
docker --help
5. docker 常用命令
# 查看docker 镜像
docker images
# 查看docker所有容器
docker ps -a
# 运行中的容器
docker ps
# 运行一个新容器
docker run
# 启动|停止|重启 已经存在的容器
docker start|stop|restart
# 导出镜像
docker save –o myapp.tar imageName (–o输出到文件)
# 导入镜像
docker load –i myapp.tar
# 删除镜像
docker rmi [镜像名称或ID]
# 删除容器
docker rm [容器名称]
# 进入容器
docker exec –it [容器名称] /bin/bash
# 查看容器日志
docker logs –f [容器名称]
来源:oschina
链接:https://my.oschina.net/u/3477333/blog/3081526
热门文章
- 动物疫苗公司排名前十名(动物疫苗公司10强)
- 宠物粮食生意怎么样啊好做吗赚钱吗(宠物粮食生意怎么样啊好做吗赚钱吗知乎)
- 兽用疫苗销售人员(兽用疫苗销售人员要求)
- 宠物店猫疫苗多少钱一针(宠物店猫疫苗多少钱一针打)
- 「3月22日」最高速度18.9M/S,2025年SSR/Clash/Shadowrocket/V2ray每天更新免费节点订阅链接
- 宠物领养app设计(宠物领养app该如何设计)
- 办理动物疫苗经营手续需要哪些 办理动物疫苗经营手续需要哪些资料
- 成都宠物领养平台怎么样啊多少钱一个(成都宠物领养平台交流微信群)
- 申请动物诊疗机构的条件和流程(申请设立动物诊疗机构)
- 狗粮在哪里进货(狗粮在哪里进货渠道)