您的位置:首页 > 运维架构 > Docker

【MD】ubuntu server 16.04离线安装docker 1.12.3的探索

2017-12-04 17:27 579 查看
原贴发表于17年初,本次使用md重新编辑并完善.

copyright:wangn

本文基于局域网环境探索docker 1.12.3在ubuntuServer上的安装

局域网安装运维docker一直是一个大问题,简而言之,ubuntu安装需要
deb安装包
,离线上传后使用脚本或者命令安装。

那么docker的离线包在哪里?

通过搜索发现,联网状态,ubuntu可以使用如下命令安装:

wget -qO- https://get.docker.com/ | sh


注意上面的网址:主页内容如下

#!/bin/sh
set -e
#
# This script is meant for quick & easy install via:
#   'curl -sSL https://get.docker.com/ | sh'
# or:
#   'wget -qO- https://get.docker.com/ | sh'
#
url="https://get.docker.com/"
apt_url="https://apt.dockerproject.org"
yum_url="https://yum.dockerproject.org"
gpg_fingerprint="58118E89F3A912897C070ADBF76221572C52609D"


通过截取的部分内容得知,apt源在
https://apt.dockerproject.org
,打开后逐层查看,可以在

https://apt.dockerproject.org/repo/pool/main/d/docker-engine/
下发现所有ubuntu docker安装包。至于罗列了很多版本,怎么区分?请参考:http://packages.ubuntu.com/

好了,到了这一步,我们知道ubuntu server 16.04的代号为
xenial (16.04LTS)


下载
docker-engine_1.12.3-0~xenial_amd64.deb
链接:
https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_1.12.3-0~xenial_amd64.deb


将deb文件上传到离线服务器并安装:

# dpkg -i docker-engine_1.12.3-0-xenial_amd64.deb
(Reading database ... 98080 files and directories currently installed.)
Preparing to unpack docker-engine_1.12.3-0-xenial_amd64.deb ...
Unpacking docker-engine (1.12.3-0~xenial) over (1.12.3-0~trusty) ...
dpkg: dependency problems prevent configuration of docker-engine:
docker-engine depends on libltdl7 (>= 2.4.6); however:
Package libltdl7 is not installed.
dpkg: error processing package docker-engine (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu10) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
docker-engine


此时报错了,缺少
libltdl7
组件,这个多少版本?哪里去找?

我们找到一台联网的机器,安装测试。

# apt-get install -y libltdl7
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libltdl7
0 upgraded, 1 newly installed, 0 to remove and 60 not upgraded.
1 not fully installed or removed.
Need to get 38.3 kB of archives.
After this operation, 85.0 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libltdl7 amd64 2.4.6-0.1 [38.3 kB]
Fetched 38.3 kB in 0s (47.2 kB/s)
Selecting previously unselected package libltdl7:amd64.
(Reading database ... 98080 files and directories currently installed.)
Preparing to unpack .../libltdl7_2.4.6-0.1_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-0.1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Setting up libltdl7:amd64 (2.4.6-0.1) ...
Setting up docker-engine (1.12.3-0~xenial) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu10) ...
Processing triggers for ureadahead (0.100.0-19) ...


测试发现,缺少的文件为
libltdl7_2.4.6-0.1_amd64.deb


https://pkgs.org/
搜索
libltdl7
,得到如下结果



那现在下载
libltdl7_2.4.6-0.1_amd64.deb
,与
docker-engine_1.12.3-0-xenial_amd64.deb
一起上传到离线服务器并安装:

# dpkg -i *.deb
Selecting previously unselected package docker-engine.
(Reading database .
4000
.. 90992 files and directories currently installed.)
Preparing to unpack docker-engine_1.12.3-0-xenial_amd64.deb ...
Unpacking docker-engine (1.12.3-0~xenial) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack libltdl7_2.4.6-0.1_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-0.1) ...
Setting up libltdl7:amd64 (2.4.6-0.1) ...
Setting up docker-engine (1.12.3-0~xenial) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu10) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...


安装成功,启动docker服务

# service docker start


查看服务状态

# service docker status
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2016-11-14 02:41:45 CST; 17s ago
Docs: https://docs.docker.com Main PID: 32152 (dockerd)
CGroup: /system.slice/docker.service
├─32152 /usr/bin/dockerd -H fd://
└─32159 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-int
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.577946151-06:00" level=warning msg="Your kernel does not support swap memory l
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.578354605-06:00" level=info msg="Loading containers: start."
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.664555247-06:00" level=info msg="Firewalld running: false"
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.797725110-06:00" level=info msg="Default bridge (docker0) is assigned with an
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.845300756-06:00" level=info msg="Loading containers: done."
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.845412034-06:00" level=info msg="Daemon has completed initialization"
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.845429551-06:00" level=info msg="Docker daemon" commit=6b644ec graphdriver=auf
Nov 14 02:41:45 ubuntu dockerd[32152]: time="2016-11-14T02:41:45.851552715-06:00" level=info msg="API listen on /var/run/docker.sock"
Nov 14 02:41:45 ubuntu systemd[1]: Started Docker Application Container Engine.
Nov 14 02:41:58 ubuntu systemd[1]: Started Docker Application Container Engine.


查看docker版本信息

# docker version
Client:
Version:      1.12.3
API version:  1.24
Go version:   go1.6.3
Git commit:   6b644ec
Built:        Wed Oct 26 22:01:48 2016
OS/Arch:      linux/amd64

Server:
Version:      1.12.3
API version:  1.24
Go version:   go1.6.3
Git commit:   6b644ec
Built:        Wed Oct 26 22:01:48 2016
OS/Arch:      linux/amd64


测试docker

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@ubuntu:/home# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
root@ubuntu:/home# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

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.
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 Hub account: https://hub.docker.com 
For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ 
root@ubuntu:/home# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
c1dc24d6da4a        hello-world         "/hello"            10 seconds ago      Exited (0) 10 seconds ago                       jovial_bhaskara
root@ubuntu:/home# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              c54a2cc56cbb        4 months ago        1.848 kB


【总结】

1、相信你已经知道如何离线安装并掌握在线安装逻辑了;

2、安装命令及代码中往往隐藏着奥秘;

3、https://pkgs.org/ 可以找到linux相关的安装包,可供离线下载,当然专业的包需要专门的网址下单,比如docker。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息