Docker 内网环境安装指南
- 查看操作系统信息,后面在下载对应的docker安装程序包时需要用到
使用命令
lsb_release -a
,注意查看Codename信息
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial --- 下载docker安装包
下载docker安装包 版本地址 https://download.docker.com/linux/ubuntu/dists/ 根据上面的Codename信息,选择对应的版本。如上面的Ubuntn对应的docker安装程序路径为 https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce17.03.2~ce-0~ubuntu-xenialamd64.deb
可以在windows系统中下载后上传到Ubuntu机器上,或者按照下面的步骤设置操作系统代理后,通过wget命令下载 切换到docker安装程序所在目录 dpkg -i docker安装程序文件名执行安装操作
如果安装过程中提示缺少libltdl7依赖包,手动下载libltdl7包,安装后,重新执行docker安装 libltdl7下载地址:http://launchpadlibrarian.net/236916213/libltdl72.4.6-0.1amd64.deb修改系统代理 编辑 /etc/profile文件,在文件后面追加代理信息 httpproxy=http://域名:密码@proxyhk.soft256.com:8080
httpsproxy=http://域名:密码@proxyhk.soft256.com:8080
ftpproxy=http://域名:密码@proxyhk.soft256.com:8080
//不想加入代理的域名或者IP noproxy=localhost,10.,127.0.0.1,.soft256.com,100.109.33.7,10.179.109.130,10.120.83.8,docker-hub.tools.soft256.com
export httpproxy httpsproxy ftpproxy noproxy
执行source /etc/profile
执行env命令查看环境变量env是否有代理信息 使用curl http://www.google.com 查看代理是否成功修改docker代理 mkdir -p /etc/systemd/system/docker.service.d
在这个目录下新建http-proxy.conf 和 https-proxy.conf [Service] Environment="HTTPPROXY=http://username:password@proxyhk.soft256.com:8080" "NOPROXY=localhost,127.0.0.1,docker-hub.tools.soft256.com,*.soft256.com"
systemctl daemon-reload
systemctl restart docker
查看服务的环境变量是否生效 systemctl show --property=Environment docker
运行 docker run hello-world 查看是否能够从docker官网下载镜像
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/engine/userguide/
4.配置私有镜像仓库地址
修改 /etc/docker/daemon.json文件
{
"registry-mirrors": ["https://XXXX.com","docker-hub.tools.soft256.com"],
//取消安全认证?
"insecure-registries" : ["docker-hub.tools.soft256.com"]
}
5.使用docker info
查看docker安装详情
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 17.03.2-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 3
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-62-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.774 GiB
Name: SZV1000350469
ID: 2UHF:R4YA:ACEX:PPLE:4RNI:LZGT:CNBD:WBXZ:HFMP:O7GH:YEAE:I6TU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Http Proxy: http://username:password@proxyhk.soft256.com:8080
Https Proxy: http://username:password@proxyhk.soft256.com:8080
No Proxy: localhost,127.0.0.1,docker-hub.tools.soft256.com,*.soft256.com
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
docker-hub.tools.soft256.com
127.0.0.0/8
Registry Mirrors:
https://uo0hqeee.mirror.aliyuncs.com
docker-hub.tools.soft256.com
Live Restore Enabled: false
PS:启动失败时查看启动状态
systemctl status docker.service
参考文档地址
https://docs.docker.com/install/linux/docker-ce/centos/#upgrade-docker-ce-1
https://docs.docker.com/config/daemon/systemd/#httphttps-proxy