Centos7离线安装Docker

工作原因需要在客户现场离线安装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 [容器名称]

 

转载于:https://my.oschina.net/u/3477333/blog/3081526

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值