二进制安装docker

有些场景不得不采用二进制安装docker,例如:客户内网机房环境。
本文参考官网文档: https://docs.docker.com/engine/install/binaries/#install-daemon-and-client-binaries-on-linux

1. 下载docker二进制版本

请选择最新最稳定的CE版本
https://download.docker.com/linux/static/stable/x86_64/

例如 :下载版本为18.06.3-ce的docker二进制压缩包到 /tmp目录下:

[root@localhost tmp]# wget  https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz

2. 解压出二进制文件

解压出的一个文件目录为 docker/

[root@localhost tmp]# tar -xvf docker-18.06.3-ce.tgz
[root@localhost tmp]# ls
docker  docker-18.06.3-ce.tgz

3. 复制二进制文件到/usr/bin目录下

[root@localhost tmp]# cp docker/* /usr/bin/

4. 检查docker命令是否可用

[root@localhost tmp]# docker --version
Docker version 18.06.3-ce, build d7080c1

5. 配置systemctl 启动命令并设置开机启动

以上步骤安装成功后,shell命令行下 sudo dockerd & 即可启动docker,但一般我们采用 systemctl 方式启动docker服务并设置开机启动

创建 /usr/lib/systemd/system/docker.service 文件

[root@localhost tmp]# vim /usr/lib/systemd/system/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

采用 systemctl 设置自动重启

[root@localhost tmp]# systemctl daemon-reload
[root@localhost tmp]# systemctl start docker.service

# --------------设置开机自动启动-------------------
[root@localhost tmp]# sudo systemctl enable docker

6. 验证docker 是完成安装

[root@localhost tmp]# ps aux|grep docker
root       1828  0.7  2.5 637736 47572 ?        Ssl  18:39   0:01 /usr/bin/dockerd
root       1973  1.0  1.4 349884 26156 ?        Ssl  18:39   0:01 docker-containerd --config /var/run/docker/containerd/containerd.toml
root       2822  0.0  0.0  12108  1056 pts/0    S+   18:42   0:00 grep --color=auto docker

# 第一次运行该命令,本地镜像不存在,docker会自动从dockerhub上下载该镜像
[root@localhost tmp]# docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/


  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值