云计算:Docker安装及本地镜像仓库配置

# **Docker的安装及如何配置从国内镜像中拖取需要的images到本地使用**

实验环境:

OS:CentOS7.0 -X64

上网环境:通过代理服务器上网

1.首先下载docker安装包docker-engine-1.7.1-1.el7.centos.x86_64.rpm

安装包下载地址:

https://get.docker.com/rpm/1.7.1/centos-7/RPMS/x86_64/docker-engine-1.7.1-1.el7.centos.x86_64.rpm

[[email protected] ~]# rpm -ivh docker-engine-1.7.1-1.el7.centos.x86_64.rpm   #安装docker包

[[email protected] ~]# service docker start   #启动docker服务

Starting docker (via systemctl):            [  OK  ]

[[email protected] ~]# docker ps    #查看docker驱动的进程,目前暂时没有驱动进程

CONTAINER ID     IMAGE       COMMAND       CREATED         STATUS        PORTS          NAMES

[[email protected] ~]# docker images   #查看docker镜像文件,初始安装没有镜像

REPOSITORY        TAG        IMAGE ID         CREATED         VIRTUAL SIZE

2.配置服务器代理上网:由于上网环境是通过代理上网,所以本台测试机器需要配置代理才可以上网。

配置方法如下:编辑/etc/profile  添加以下内容

http_proxy=192.168.1.100:8005     #根据实际情况设定自己的代理服务器

https_proxy=$http_proxy

http_proxy_username=test        #如果代理需要通过用户名和密码验证则设置,如果不需要验证username和password则可以不设定。

http_proxy_password=12356

no_proxy=192.*.*.*,*.local,localhost,127.0.0.1  #设定不需要代理的ip

[[email protected] ~]# ping baidu.com  #测试ping百度,连接成功,配置外网代理成功。

PING baidu.com (220.181.57.216) 56(84) bytes of data.

64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=51 time=30.7 ms

64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=51 time=33.4 ms

64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=51 time=34.0 ms

以为通过上述设定就可以通过 docker pull [images名称] 下载docker镜像文件,结果报以下错误:

[[email protected] ~]# docker pull daocloud.io/library/node:8.1.0-slim  #通过pull命令,提示的报错,反正我也没看懂,所以就网上搜索

一下,找了很多方法,总算找到了原因,是由于docker需要再单独配置代理上网。

Error response from daemon: invalid registry endpoint https://daocloud.io/v0/: unable to ping registry endpoint https://daocloud.io/v0/

v2 ping attempt failed with error: Get https://daocloud.io/v2/: remote error: handshake failure

v1 ping attempt failed with error: Get https://daocloud.io/v1/_ping: remote error: handshake failure. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry daocloud.io` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/daocloud.io/ca.crt

3.配置docker代理上网,新增以下配置文件

[[email protected] ~]# vim /etc/systemd/system/docker.service.d/http-proxy.conf #新增代理配置文件,内容如下:

[Service]

Environment="HTTP_PROXY=10.109.134.247:8005"

Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"

保存退出,再次使用pull命令下载成功,可以使用pull命令下载镜像了,总算搞定了。

[[email protected] ~]# docker images   #查看docker镜像文件,初始安装没有镜像

REPOSITORY        TAG        IMAGE ID         CREATED         VIRTUAL SIZE

[[email protected] ~]# docker pull busybox   #通过pull下载busybox镜像到本地镜像仓库。

latest: Pulling from busybox

f9ea5e501ad7: Pull complete

ac3f08b78d4e: Pull complete

Digest: sha256:da268b65d710e5ca91271f161d0ff078dc63930bbd6baac88d21b20d23b427ec

Status: Downloaded newer image for busybox:latest   #下载busybox镜像成功

[[email protected] docker]# docker pull daocloud.io/library/nginx:latest  #下载nginx镜像成功

latest: Pulling from daocloud.io/library/nginx

2cd56ba950c8: Pull complete

8ecf8a9b915f: Pull complete

2f035d3cb1ca: Pull complete

33ff728209b6: Pull complete

a8788126754a: Pull complete

534bc4991cb2: Pull complete

4eff2ba6990a: Pull complete

ca14437b52c6: Pull complete

64d6b4f35a10: Pull complete

476b0368435b: Pull complete

Digest: sha256:cb29ee85b234f356fb8a77d8cfb78b42355f7f016f528f11a2a5f75e4862dc94

Status: Downloaded newer image for daocloud.io/library/nginx:latest

[[email protected] docker]# docker images     #再次查看本地镜像仓库,已经有2个刚下载的镜像。

REPOSITORY             TAG         IMAGE ID           CREATED          VIRTUAL SIZE

daocloud.io/library/nginx   latest       476b0368435b        7 days ago          108.9 MB

busybox               latest       ac3f08b78d4e        12 days ago          1.146 MB

原文地址:http://blog.51cto.com/woyaoxuelinux/2104914

时间: 2024-08-09 20:33:54

云计算:Docker安装及本地镜像仓库配置的相关文章

10、《每天5分钟玩转Docker容器技术》学习-Docker命令之本地镜像管理

a) Docker images 命令 docker images : 列出本地镜像. docker images [OPTIONS] [REPOSITORY[:TAG]] -a :列出本地所有的镜像(含中间映像层,默认情况下,过滤掉中间映像层): --digests :显示镜像的摘要信息: -f :显示满足条件的镜像: --format :指定返回值的模板文件: --no-trunc :显示完整的镜像信息: -q :只显示镜像ID. l 实例 查看本地镜像列表. 列出本地镜像中REPOSITO

centos 安装 网络安装使用本地镜像文件安装

有时很无奈,无磁盘,U盘就只有4G而一个centos的盘是4.16G,如何将它装好网络安装,对不起,请你要使用20M以上的带宽,且注意使用网络启动方法 没有条件,创造条件也要上: 网络安装方式,需要下载其镜像,其镜像下载路径为:http://mirrors.163.com/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-netinstall.iso 使用iso工具做一下centos的安装u盘, 具体方法,http://jingyan.baidu.com/arti

Docker安装入门 -- 中间件镜像

Docker安装入门 -- 中间件镜像 php-fpm 1.docker build -t csphere/php-fpm:5.4 .   //在当前目录下创建镜像 2.docker run -d -p 8080:80 --name website csphere/php-fpm:5.4   //生成website容器 3.http://192.168.137.21:8080/info.php //浏览器访问 4.docker exec -it website /bin/bash   //进入一

springboot等javaweb项目将jar包安装到本地Maven仓库

在开发过程中有时会用到maven仓库里没有的jar包或者本地的jar包 1.打开jar所在文件夹,假设我们要将 taobao-sdk-java-auto_1479188381469-20200121.jar 安装到本地Maven仓库 mvn install:install-file -Dfile=taobao-sdk-java-auto_1479188381469-20200121.jar -DgroupId=com.dingtalk.open -DartifactId=taobao-sdk-j

设置docker本地镜像仓库

1.部署docker registry1.1 拉取registry镜像#docker pull docker.io/registry Trying to pull repository docker.io/library/registry ... sha256:0e40793ad06ac099ba63b5a8fae7a83288e64b50fe2eafa2b59741de85fd3b97: Pulling from docker.io/library/registryb7f33cc0b48e:

Docker公共&本地镜像仓库(七)--技术流ken

分发镜像 我们已经会构建自己的镜像了,那么如果在多个docker主机上使用镜像那?有如下的几种可用的方法: 用相同的Dockerfile在其他host上构建镜像 将镜像上传到公共registry(比如docker hub),host直接下载使用 搭建私有的registry供本地的host使用 镜像命名 无论采用何种方式保存和分发镜像,首先都得给镜像命名. 通过 dock images ls 可以查看镜像的信息. [[email protected] ~]# docker image ls REP

可能是最详细的部署:Docker Registry企业级私有镜像仓库Harbor管理WEB UI

上一篇文章搭建了一个具有基础功能,权限认证.TLS 的私有仓库,但是Docker Registry 作为镜像仓库,连管理界面都没有,甚至连一些运维必备的功能都是缺失的,还有什么 Docker 镜像仓库管理工具呢?这里有一个简单好用的企业级 Registry 服务器 - Harbor,推荐在生产环境上使用. Harbor 简介 Harbor是VMware公司开源的企业级Docker Registry项目,其目标是帮助用户迅速搭建一个企业级的Docker registry服务. 它以Docker公司

Docker——Registry搭建私有镜像仓库

前言 在 Docker 中,当我们执行 docker pull xxx 的时候,它实际上是从 registry.hub.docker.com 这个地址去查找,这就是Docker公司为我们提供的公共仓库,上面的镜像,大家都可以看到,也可以使用. 所以,我们也可以带上仓库地址去拉取镜像,如:docker pull jenkins 在公司中使用 Docker,我们不可能把商业项目上传到公共仓库中,所以要搭建私有仓库. 1.部署仓库 准备1台安装好docker的服务器 (主机名为registry):do

Docker基础-搭建本地私有仓库

1.使用registry镜像创建私有仓库 安装Docker后,可以通过官方提供的registry镜像来简单搭建一套本地私有仓库环境: docker run -d -p 5000:5000 registry 这条命令将自动下载并启动一个registry容器,创建本地的私有仓库服务.默认会将仓库创建在容器的/tmp/registry目录下.可以通过-v参数来将镜像文件存放在本地指定路径 例如:将上传的镜像放到/opt/data/registry目录: docker run -d -p 5000:50