二进制文件方式安装Docker-CE

公冶渝
2023-12-01

docker-ce提供了常用的linux发行版的安装方式,但是离线安装很多时候仍然是一个需要,这篇文章介绍了如何在centos上使用离线安装包进行docker-ce版本的安装,此方式适用于大部分docker离线安装包的安装方式。

OS

项目操作系统
No.1CentOS7/RHEL
No.2其他使用systemd的linux发行版

安装方式

安装主要进行了如下内容:

步骤详细内容
Step 1下载docker-ce的离线安装包
Step 2解压出docker目录
Step 3将docker目录下的内容拷贝到/usr/bin下并设置权限
Step 4设置docker的systemd设定文件
Step 5设定docker的开机启动
Step 6启动docker
Step 7确认版本

安装脚本

安装脚本放到了如下github上

安装脚本https://github.com/liumiaocn/easypack/blob/master/docker/install-docker.sh

安装方式

安装说明

下载离线安装包,然后将文件名作为参数传给安装脚本即可

[root@angular docker]# sh install-docker.sh 
Usage: install-docker.sh FILE_NAME_DOCKER_CE_TAR_GZ
       install-docker.sh docker-17.09.0-ce.tgz
Get docker-ce binary from: https://download.docker.com/linux/static/stable/x86_64/
eg: wget https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz

[root@angular docker]#

安装示例

下载目前最新的稳定版本的docker-ce,下载路径为:https://download.docker.com/linux/static/stable/x86_64/

[root@angular docker]# wget https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz
--2017-10-25 19:08:43--  https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz
Resolving download.docker.com (download.docker.com)... 54.182.1.17, 54.182.1.143, 54.182.1.160, ...
Connecting to download.docker.com (download.docker.com)|54.182.1.17|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30365949 (29M) [application/x-tar]
Saving to: ‘docker-17.09.0-ce.tgz’

100%[==============================================================================================>] 30,365,949   101KB/s   in 5m 35s 

2017-10-25 19:14:25 (88.5 KB/s) - ‘docker-17.09.0-ce.tgz’ saved [30365949/30365949]

[root@angular docker]#

安装

[root@angular docker]# sh install-docker.sh  docker-17.09.0-ce.tgz 
##unzip : tar xvpf docker-17.09.0-ce.tgz
docker/
docker/docker-containerd-shim
docker/docker-containerd
docker/docker-runc
docker/docker
docker/docker-init
docker/docker-containerd-ctr
docker/docker-proxy
docker/dockerd

##binary : docker copy to /usr/bin
/usr/bin/docker
##systemd service: docker.service
##docker.service: create docker systemd file

##Service status: docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://docs.docker.com
##Service restart: docker
##Service status: docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-10-25 19:18:43 EDT; 72ms ago
     Docs: http://docs.docker.com
 Main PID: 1414 (dockerd)
   Memory: 16.5M
   CGroup: /system.slice/docker.service
           ├─1414 /usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --selinux-enabled=false --log-opt max-size=1g...
           └─1418 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeo...

Oct 25 19:18:36 angular dockerd[1414]: time="2017-10-25T19:18:36.416541000-04:00" level=warning msg="failed to rename /var/lib...nously"
Oct 25 19:18:37 angular dockerd[1414]: time="2017-10-25T19:18:37.172916429-04:00" level=info msg="Graph migration to content-a...econds"
Oct 25 19:18:37 angular dockerd[1414]: time="2017-10-25T19:18:37.191385917-04:00" level=info msg="Loading containers: start."
Oct 25 19:18:41 angular dockerd[1414]: time="2017-10-25T19:18:41.000545493-04:00" level=info msg="Default bridge (docker0) is ...ddress"
Oct 25 19:18:42 angular dockerd[1414]: time="2017-10-25T19:18:42.933687222-04:00" level=info msg="Loading containers: done."
Oct 25 19:18:42 angular dockerd[1414]: time="2017-10-25T19:18:42.990164870-04:00" level=info msg="Docker daemon" commit=afdb6d...09.0-ce
Oct 25 19:18:42 angular dockerd[1414]: time="2017-10-25T19:18:42.991432362-04:00" level=info msg="Daemon has completed initialization"
Oct 25 19:18:43 angular systemd[1]: Started Docker Application Container Engine.
Oct 25 19:18:43 angular dockerd[1414]: time="2017-10-25T19:18:43.161695630-04:00" level=info msg="API listen on /var/run/docker.sock"
Oct 25 19:18:43 angular dockerd[1414]: time="2017-10-25T19:18:43.161959773-04:00" level=info msg="API listen on [::]:4243"
Hint: Some lines were ellipsized, use -l to show in full.
##Service enabled: docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
## docker version
Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:39:28 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:45:38 2017
 OS/Arch:      linux/amd64
 Experimental: false
[root@angular docker]#
 类似资料: