Registry快捷搭建私有镜像酒店,Hub旅馆下载镜像网络尤其难题的缓慢解决

By admin in 美高梅手机版4858 on 2019年5月5日

[root@MyCentos7 var]# docker pull java
Using default tag: latest
Trying to pull repository docker.io/library/java …
latest: Pulling from docker.io/library/java
5040bd298390: Pulling fs layer
fce5728aad85: Pulling fs layer
76610ec20bf5: Waiting
60170fec2151: Waiting
e98f73de8f0d: Waiting
11f7af24ed9c: Waiting
49e2d6393f32: Waiting
bb9cdec9c7f3: Waiting
error pulling image configuration: Get
:
net/http: TLS handshake timeout

 

正文记录下近期在念书Docker容器才具时遇上的片段标题,以此记录下难题浅析排查进度

1、背景

在 Docker 中,当我们推行 docker pull xxx 的时候,可能会相比较奇异,Docker
会去何地查找并下载镜像吧?

它其实是从 registry.hub.docker.com
那些地方去找寻,那就是Docker公司为大家提供的集体旅馆,上边包车型客车镜像,大家都足以见到,也能够选用。所以,大家也可以带上客栈地址去拉取镜像,如:docker
pull
registry.hub.docker.com/library/alpine,但是要注意,那种办法下载的镜像的暗许名称就社长一些。

要是要在信用合作社中利用
Docker,我们着力不恐怕把经济贸易类型上传播公共仓库中,那假使要多少个机械共享,又能如何做吧?

正因为那种必要,所以个人堆栈也就有用武之地了。

所谓个人仓库,也正是在本土(局域网)搭建的1个接近公共旅舍的事物,搭建好之后,大家得以将镜像提交到村办商旅中。那样大家既能使用
Docker 来运作大家的品种镜像,也制止了商业贸易项目暴透露来的风险。

上边大家用合法提供的registry镜像来搭建私有镜像仓库,当然还有别的众多措施。

出现这一个主题材料由来为国内互联网难题,不可能连接到 docker hub。 但国内有
 daocloud加快,docker钦点该源就能够。

 

故障难题:

2、环境

计划两台设置好docker的服务器:
服务端机器
主机名称为registry):docker私有旅馆服务器,运维registry容器;
测试端机器
主机名字为node):普通的docker服务器,在那台服务器上下载一个测试镜像busybox,然后上传到registry服务器实行测试;

centos7拍卖办法如下,增加后重启docker :

容器和
VM(虚拟机)的器重区别是,容器提供了依据进度的割裂,而虚拟机提供了财富的完全割裂。虚拟机大概供给1分钟来运行,而容器只需求一分钟或越来越短。容器使用宿主操作系统的基业,而虚拟机使用独立的基业。
Docker 的局限性之壹是,它不得不用在 64 位的操作系统上。

透过docker pull 从国有仓库Docker Hub下载镜像退步

三、布署(服务端操作)

三.壹 下载镜像registry

[root@registry ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
81033e7c1d6a: Pull complete
b235084c2315: Pull complete
c692f3a6894b: Pull complete
Registry快捷搭建私有镜像酒店,Hub旅馆下载镜像网络尤其难题的缓慢解决。ba2177f3a70e: Pull complete
a8d793620947: Pull complete
Digest:
sha256:672d519d7fd7bbc7a448d17956ebeefe225d5eb27509d8dc5ce67ecb4a0bce54
Status: Downloaded newer image for registry:latest

三.二 查看镜下是不是pull下来了
美高梅手机版4858 1

3.3 运行registry容器

[root@registry ~]# docker run -itd -v
/data/registry:/var/lib/registry -p 5000:5000 –restart=always –name
registry registry:latest
06a972de6218b1f1c3bf9b53eb9068dc66d147d14e18a89ab51db13e339d3dc9

参数表达
-itd:在容器中开荒一个伪终端实行交互操作,并在后台运营;
-v:把宿主机的/data/registry目录绑定 到
容器/var/lib/registry目录(这些目录是registry容器中存放镜像文件的目录),来贯彻多少的持久化;
-p:映射端口;访问宿主机的五千端口就访问到registry容器的劳务了;
–restart=always:那是重启的国策,假诺这么些容器非常退出会自行重启容器;
–name registry:创设容器命名称为registry,你能够不管命名;
registry:latest:这些是刚才pull下来的镜像;

三.四 测试镜像客栈中保有的镜像

[root@registry ~]# curl
{“repositories”:[]}

现行反革命是空的,因为才刚运营,里面未有其余镜像内容。

[root@MyCentos7 var]# vim /etc/sysconfig/docker

 

[root@node-11 ~]# docker pull
Ubuntu:14.04
Trying to pull repository docker.io/library/ubuntu …
14.04: Pulling from docker.io/library/ubuntu
c2c80a08aa8c: Pulling fs layer
6ace04d7a4a2: Download complete
f03114bcfb25: Pulling fs layer
99df43987812: Waiting
9c646cd4d155: Waiting
error pulling image configuration: Get
:
net/http: TLS handshake timeout

四、测试镜像仓库(测试端操作)

四.一 修改下镜像源不分轩轾启docker服务

[root@node ~]# vim /etc/docker/daemon.json
{
  “registry-mirrors”: [ “]
}

[root@node ~]# systemctl restart docker

4.1 下载busybox镜像

[root@node ~]# docker pull busybox
[root@node ~]# docker images
REPOSITORY          TAG                IMAGE ID            CREATED     
      SIZE
busybox            latest              f6e427c148a7        36 hours ago 
      1.15MB

四.二 为镜像打标签

[root@node ~]# docker tag busybox:latest 
172.18.18.90:5000/busybox:v1

格式表明:Usage: docker tag SOU陆风X八CE_IMAGE[:TAG] TARGET_IMAGE[:TAG] 

busybox:lastest 这是源镜像,也是刚才pull下来的镜像文件;
17二.18.1八.90:500/busybox:v一:那是目的镜像,也是registry私有镜像服务器的IP地址和端口;

翻看一下打好的tag:
美高梅手机版4858 2

4.三 上传到镜像服务器

[root@node ~]# docker push 172.18.18.90:5000/busybox:v1
The push refers to repository [172.18.18.90:5000/busybox]
Get : http: server gave HTTP response to
HTTPS client

留神了,这是报错了,需求https的格局才干上传,我们得以修改下daemon.json来减轻:

[root@node ~]# vim /etc/docker/daemon.json
{
  “registry-mirrors”: [ “],
  “insecure-registries”: [ “172.18.18.90:5000”]
}

增多私有镜像服务器的地点,注意书写格式为json,有严厉的书写须要,然后重启docker服务:

[root@node ~]# systemctl  restart docker

在次上传能够观望没难题 了:

[root@node ~]# docker push 172.18.18.90:5000/busybox:v1
The push refers to repository [172.18.18.90:5000/busybox]
c5183829c43c: Pushed
v1: digest:
sha256:c7b0a24019b0e6eda714ec0fa137ad42bc44a754d9cea17d14fba3a80ccc1ee4
size: 527

四.四 测试下载镜像
上传测试没难点了,大家接下去测试一下从registry服务器上下载刚才上传的busybox镜像,先删除node主机上的镜像:

[root@node ~]# docker rmi -f $(docker images -aq)
Untagged: 172.18.18.90:5000/busybox:v1
Untagged:
172.18.18.90:5000/busybox@sha256:c7b0a24019b0e6eda714ec0fa137ad42bc44a754d9cea17d14fba3a80ccc1ee4
Untagged: busybox:latest
Untagged:
busybox@sha256:2107a35b58593c58ec5f4e8f2c4a70d195321078aebfadfbfb223a2ff4a4ed21
Deleted:
sha256:f6e427c148a766d2d6c117d67359a0aa7d133b5bc05830a7ff6e8b64ff6b1d1d
Deleted:
sha256:c5183829c43c4698634093dc38f9bee26d1b931dedeba71dbee984f42fe1270d

查看一下node主机上的镜像全部删除了:

[root@node ~]# docker images
REPOSITORY          TAG                IMAGE ID            CREATED     
      SIZE

下一场,从registry服务器上下载busybox镜像:

[root@node ~]# docker pull 172.18.18.90:5000/busybox:v1
v1: Pulling from busybox
d070b8ef96fc: Pull complete
Digest:
sha256:c7b0a24019b0e6eda714ec0fa137ad42bc44a754d9cea17d14fba3a80ccc1ee4
Status: Downloaded newer image for 172.18.18.90:5000/busybox:v1
[root@node ~]# docker images
REPOSITORY                  TAG                IMAGE ID           
CREATED            SIZE
172.18.18.90:5000/busybox  v1                  f6e427c148a7        36
hours ago        1.15MB

列出全部镜像:

[root@node ~]# curl 
{“repositories”:[“busybox”]}

列出busybox镜像有怎么样tag:

[root@node ~]# curl 
{“name”:”busybox”,”tags”:[“v1”]}

越来越多Docker相关教程见以下内容: 

Docker安装应用(CentOS
6.5_x64)
Ubuntu 1陆.04服务器上布置使用 Docker 

Ubuntu 15.04下安装Docker 

Docker 安装实例
Docker 创造基础镜像 

在 Ubuntu 1伍.0④ 上哪些设置Docker及着力用法

Ubuntu 1陆.04上Docker使用手记

利用Docker分分钟开发银行常用应用 

Ubuntu 1陆.0四下Docker修改配置文件不见效化解办法 

Docker
的事无巨细介绍
:请点这里
Docker
的下载地址
:请点这里

本文永远更新链接地址

美高梅手机版4858 3

革命字体为增进内容

docker 是二个linux 上的LXC
容器项目,是很轻量级的虚拟化技能。

因为自个儿办公区互连网无法再揶揄,导致力不从心去Docker
Hub货仓下载镜像。可以通过陈设国内 daocloud镜像源化解那么些标题。

# /etc/sysconfig/docker

docker即便基于lxc才具(cgroup、namespace等),不过思路完全和lxc分歧等。

编辑/etc/sysconfig/docker配置文件,在OPTIONS=’–selinux-enabled
–log-driver=journald –signature-verification=false
前面加多国内的docker镜像源–registry-mirror=

# Modify these options if you want to change the way the docker daemon
runs
OPTIONS=’–selinux-enabled –log-driver=journald
–signature-verification=false
–registry-mirror=’
if [ -z “${DOCKER_CERT_PATH}” ]; then
DOCKER_CERT_PATH=/etc/docker
fi

lxc看起来更像是三个虚拟机,多用来操作系统级其余虚拟化,背后的军事学是
IAAS;

美高梅手机版4858 4

# Do not add registries in this file anymore. Use
/etc/containers/registries.conf
# from the atomic-registries package.
#

而docker看起来是五个顺序,跑在沙箱里的次序,属于应用程序等第的虚拟化,背后的理学是
PAAS。

增多后重启docker 服务,就能够化解网络影响下载难题

# On an SELinux system, if you remove the –selinux-enabled option,
you
# also need to turn on the docker_transition_unconfined boolean.
# setsebool -P docker_transition_unconfined 1

凯雷德HEL 6.伍 起首提供docker 补助,大家应用
CentOS 六.陆 x6四 举行尝试。

[root@node-11 ~]# systemctl restart docker
[root@node-11 ~]# docker pull ubuntu:14.04
Trying to pull repository docker.io/library/ubuntu …
14.04: Pulling from docker.io/library/ubuntu
c2c80a08aa8c: Pull complete
6ace04d7a4a2: Pull complete
f03114bcfb25: Pull complete
99df43987812: Pull complete
9c646cd4d155: Pull complete
Digest:
sha256:ecc95bdd86160924520fdfafebfbff676cbe278d985fec0797f27d141fcde56b
Status: Downloaded newer image for docker.io/ubuntu:14.04

# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp

 

本文长久更新链接地址

# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false

Alibaba价值
商业

美高梅手机版4858 5

# docker-latest daemon can be used by starting the docker-latest
unitfile.
# To use docker-latest client, uncomment below lines
#DOCKERBINARY=/usr/bin/docker-latest
#DOCKERDBINARY=/usr/bin/dockerd-latest
#DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
#DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest

传统

[root@MyCentos7 var]# service docker restart

当下
Alibaba那样的电商带来的最大价值在于下落了商品的社会交易费用

[root@MyCentos7 var]# docker pull java
Using default tag: latest
Trying to pull repository docker.io/library/java …
latest: Pulling from docker.io/library/java
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
60170fec2151: Pull complete
e98f73de8f0d: Pull complete
11f7af24ed9c: Pull complete
49e2d6393f32: Pull complete
bb9cdec9c7f3: Pull complete
Digest:
sha256:5d6cc05636c16abb3e49f2117fd6aa4bddb8f0d775075972a8b9b03f754ea9f2
Status: Downloaded newer image for docker.io/java:latest

docker价值
未来大家把生意发展的逻辑搬到软件提交这里。古板的软件提交面临同守旧商业类似的主题素材:

成功

传统
软件开垦者和软件使用者双方消息不对称。纵然开荒者对软件的代码编写翻译、参数配置、运转情状等新闻一览了然,但使用者却很或者井蛙之见。因而,大家会平时看到使用者抱怨,明明依据用户手册一步步操作,却还是跑不起来。那种状态也不时出现在软件流程中,开荒将先后和文档交付给测试或运行,测试或运转却连连不能再现期望的运作境况,几经辗转发掘是机械情况、系统景况、软件正视版本、参数配置等等原因产生。那样不行的软件流程将使持续集成与不断绝关系付很难真正推行起来,仅仅流于格局。

 

当下
Docker之所以如此受人瞩目,并不是因为它创建了多么美妙的技艺,而是因为它再也定义了软件的交付形式,进而将改换古板“开采-测试-布署”的软件流程。特别是在云计算和开源软件大行其道的前日,Docker的产出恰恰契合了一代的上进,占尽了独具特殊的优越条件人和。

Docker的出现则将软件从开垦方到使用方的交由进度变得聚集国化学工业进出口总公司、标准化、透明化:

   
聚集国化学工业进出口总公司:软件使用者能够从Docker货仓找到五颜六色标软件镜像,叁个镜像包括商业软件或开源软件,也得以分包单个软件或私自的软件组合。
   
规范化:Docker镜像的“打造-公布-存款和储蓄-下载-运转”是标准的,统1通过Docker工具来实行,而且具备操作都能够移植到任性的机械或平台。
   
透明化:Docker镜像是自包罗的,包涵程序、软件信赖、参数配置等全体运维条件,使用者无需驾驭细节,只需运转同样的Docker命令就能够落得与开拓者一样的周转意况。

汇总,能够说Docker带来的最大价值在于降低了软件的交给资金。

在生产情状中留存的难点
Docker的发展势头1天比一天强劲,它明显在妄图减轻实际的难点。然则,对当今众多的生育情状用户来讲,未有出现优点压倒缺点的范畴。在付出、测试和连绵集成等情况下,Docker在让容器吸引相近开荒职员方面确实有上佳的显现,不过它还尚无颠覆生产意况。

从20一三年起,负担Docker开源项目标经济贸易商铺Docker,
Inc.,早先着力容器虚拟化的商海。近期,包蕴富有LXD本事的Canonical以及有着Rocket才具的CoreOS等其余供应商,也先河进入容器市镇。

[root@kvm2 ~]# yum install docker

Dependencies Resolved

=============================================================================================================================================================================================================================================
 Package                                                           
Arch                                             
Version                                                       

Repository                                         Size

Installing:
 docker                                                            
x86_64                                           
1.9.1-40.el7.centos                                           
extras                                            7.8 M
Installing for dependencies:
 docker-common                                                     
x86_64                                           
1.9.1-40.el7.centos                                           
extras                                             55 k
 docker-forward-journald                                           
x86_64                                           
1.9.1-40.el7.centos                                           
extras                                            827 k
 docker-selinux                                                    
x86_64                                           
1.9.1-40.el7.centos                                           
extras                                             73 k

Transaction Summary

Install  1 Package (+3 Dependent packages)

[root@kvm2 ~]# systemctl status docker -l
   docker.service – Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled;
vendor preset: disabled)
   Active: active (running) since Sun 2016-06-12 11:01:52 CST; 10s ago
     Docs:
 Main PID: 5881 (sh)
   CGroup: /system.slice/docker.service
           ├─5881 /bin/sh -c /usr/bin/docker-current daemon
$OPTIONS            $DOCKER_STORAGE_OPTIONS           
$DOCKER_NETWORK_OPTIONS            $ADD_REGISTRY           
$BLOCK_REGISTRY            $INSECURE_REGISTRY            2>&1 |
/usr/bin/forward-journald -tag docker
           ├─5882 /usr/bin/docker-current daemon –selinux-enabled
           └─5883 /usr/bin/forward-journald -tag docker

Jun 12 11:01:51 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:51.866493994+08:00″ level=warning msg=”Docker
could not enable SELinux on the host system”
Jun 12 11:01:51 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:51.891206059+08:00″ level=info msg=”Firewalld
running: false”
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:52.010246032+08:00″ level=info msg=”Default
bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon
option –bip can be used to set a preferred IP address”
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:52.847400089+08:00″ level=info msg=”Loading
containers: start.”
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:52.847530886+08:00″ level=info msg=”Loading
containers: done.”
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:52.847625100+08:00″ level=info msg=”Daemon has
completed initialization”
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:52.847640536+08:00″ level=info msg=”Docker
daemon” commit=”ab77bde/1.9.1″ execdriver=native-0.2
graphdriver=devicemapper version=1.9.1
Jun 12 11:01:52 kvm2.zf.com forward-journal[5883]:
time=”2016-06-12T11:01:52.856632634+08:00″ level=info msg=”API listen on
/var/run/docker.sock”
Jun 12 11:01:52 kvm2.zf.com systemd[1]: Started Docker Application
Container Engine.

[root@kvm2 ~]# docker version
Client:
 Version:         1.9.1
 API version:     1.21
 Package version: docker-common-1.9.1-40.el7.centos.x86_64
 Go version:      go1.4.2
 Git commit:      ab77bde/1.9.1
 Built:
 OS/Arch:         linux/amd64

Server:
 Version:         1.9.1
 API version:     1.21
 Package version: docker-common-1.9.1-40.el7.centos.x86_64
 Go version:      go1.4.2
 Git commit:      ab77bde/1.9.1
 Built:
 OS/Arch:         linux/amd64

 

寻找镜像
man docker search
Search Docker Hub for images that match the specified TERM.

下载镜像
man docker pull
pulls down an image or a repository from a registry.

docker pull registry.hub.docker.com/fedora:20

If you do not specify a REGISTRY_HOST, the command uses Docker’s public
registry located at registry-1.docker.io by default.

docker pull centos

默许下载库名称叫centos,tag为latest的镜像,不然就钦命registry/repository:tag

 

查阅镜像

To list the images in a local repository (not the registry) run:
docker images
This command lists the images stored in the local Docker repository.

The title REPOSITORY for the first title may seem confusing. It is
essentially the image name

运营镜像
man docker run
docker-run – Run a command in a new container
docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

翻看容器
man docker ps

美高梅手机版4858 , 

加盟–no-trunc=true这么些选项就不会截断描述列了。

[root@kvm2 ~]# docker history --no-trunc=true  d6d 
IMAGE                                                              CREATED             CREATED BY                                                                                                                      SIZE                COMMENT
d6d9ec2e67f1389197bf61eb8c07ba782dbe480bae1ea775dd1992ee5f632e4b   4 weeks ago         /bin/sh -c #(nop) CMD ["supervisord" "-n"]                                                                                      0 B                 
f818b50199268782cbac6930cda936d3ef4c390f95acd4b8fe2c07cf1fa33ff4   4 weeks ago         /bin/sh -c #(nop) EXPOSE 22/tcp 443/tcp 80/tcp                                                                                  0 B                 
afa600610768c5815a1cb7ad539f58a8d9e218246e31bde380be46636f1d9a9d   4 weeks ago         /bin/sh -c #(nop) ADD file:c987af8588740fdd52d1bfbb399323e51fb87f254fce88dc541312d3170307a1 in /etc/                            1.414 kB            
1aa4911f40c7d92d33da1ad1431c32a04be94509084ba2bfca5e7efe0b52a091   4 weeks ago         /bin/sh -c #(nop) ADD file:77dbd518f0925a02442836e97b8840c54a3e7c1658bf60dac904ee540127c08e in /var/www/html/                   22 B                
ee207207752fe93d37e59a6a6f583a2996e28ffd057bb40470ca853826c8978a   4 weeks ago         /bin/sh -c mkdir -p /root/.ssh && touch /root/.ssh/authorized_keys && chmod 700 /root/.ssh                                      0 B                 
b03bf16299774b8a0272ecc53d97041d40ba2dc8ac11dc82f9acaf509058afe1   4 weeks ago         /bin/sh -c sed -ri 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config && echo 'root:changeme' | chpasswd                           5.044 kB            
3f97351ce7a954e2a7474d7942a0151723bdc6f0eee450e9ca1c5e3d75854632   4 weeks ago         /bin/sh -c ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key && ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key   3.353 kB            
341fee58aa0f9fbac5552729659d342d8476e57f2ea03813ba8397e3231c1ce1   4 weeks ago         /bin/sh -c yum install -y openssh-server openssh-clients passwd                                                                 17.02 MB            
4121ea2cc40134f7a06e050977e3ac9f9915076dae488a54f97d1875b6fd1a2e   4 weeks ago         /bin/sh -c pip install supervisor                                                                                               2.707 MB            
724c96ad712b19ea281f55b49a6b2dc2cce151babe0e5b595289a6b7cd3ea677   4 weeks ago         /bin/sh -c yum install -y python-pip && pip install "pip>=1.4,<1.5" --upgrade                                                   18.18 MB            
306cfb3b53df0671704091ed4a3620d08d30cf11bcc8736d474e48443b893cdc   4 weeks ago         /bin/sh -c yum install -y php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml               50.27 MB            
5c0d565c6fa254516c514a8ad5ec2f370351e516e8fb8f0d33ad7085e583970e   4 weeks ago         /bin/sh -c service mysqld start                                                                                                 21.84 MB            
4fd77ea1aba2a4dcdfcbffd61a79c50e6b528663213aa6454d3fef80dcd7d82c   4 weeks ago         /bin/sh -c echo "NETWORKING=yes" > /etc/sysconfig/network                                                                       15 B                
205a003e4718da4ddfba7b9595a89274ba3a0c0bd6833e9123d7b80c1c5bbb48   4 weeks ago         /bin/sh -c yum install -y mysql mysql-server                                                                                    47.11 MB            
5f5b0aafb036866c5b87fe5c5777698f19f734bdc1520d50cafadfc7d1ecf655   4 weeks ago         /bin/sh -c yum -y install httpd vim-enhanced bash-completion unzip                                                              168.3 MB            
b10e99758b954c268ac3fe6a9b28e148604222155f3d693f8c297583d027c25e   4 weeks ago         /bin/sh -c rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm                                      10.34 MB            
4a98883d437e364a6d103abdebfcb88c026af9c09aa43e8cb83c2e6b1a2e746a   4 weeks ago         /bin/sh -c #(nop) MAINTAINER Nicholas Istre <nicholas.istre@e-hps.com>                                                          0 B                 
d65a92bab695a23057d02823b5d718822faaa413641f719764dc82bd47e6ea61   8 months ago        /bin/sh -c #(nop) ADD file:9ff85de7a936502e83fadeed82d6f11231ce7e842eea23d73f6f5fb7182f1111 in /                                202.6 MB            
3690474eb5b4b26fdfbd89c6e159e8cc376ca76ef48032a30fa6aafd56337880   14 months ago       /bin/sh -c #(nop) MAINTAINER The CentOS Project <cloud-ops@centos.org> - ami_creator                                            0 B             

 

[root@kvm2 ~]# docker search –no-trunc=true centos
INDEX       NAME                                     
DESCRIPTION                                                                                  
STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/centos                          The official build
of
CentOS.                                                                
2323      [OK]
docker.io   docker.io/jdeathe/centos-ssh              CentOS-6 6.7
x86_64 / CentOS-7 7.2.1511 x86_64 – SCL/EPEL/IUS Repos / Supervisor /
OpenSSH.   25                   [OK]
docker.io   docker.io/jdeathe/centos-ssh-apache-php   CentOS-6 6.7
x86_64 / Apache / PHP / PHP Memcached / PHP
APC.                                 17                   [OK]
docker.io   docker.io/nimmis/java-centos              This is docker
images of CentOS 7 with different versions of
java                             12                   [OK]
docker.io   docker.io/million12/centos-supervisor     Base CentOS-7 with
supervisord launcher, highly
extensible.                                   11                  
[OK]
docker.io   docker.io/consol/centos-xfce-vnc          Centos container
with “headless” VNC session and preinstalled Firefox and Chrome
browser      9                    [OK]
docker.io   docker.io/torusware/speedus-centos        Always updated
official CentOS docker image with Torusware Speedus acceleration
software      8                    [OK]
docker.io   docker.io/nickistre/centos-lamp           LAMP on centos
setup                                                                         
4                    [OK]
docker.io  
docker.io/centos/mariadb55-centos7                                                                                                     
3                    [OK]
docker.io   docker.io/nathonfowlie/centos-jre         Latest CentOS
image with the JRE
pre-installed.                                              
3                    [OK]
docker.io   docker.io/consol/sakuli-centos-xfce       Sakuli end-2-end
testing and monitoring container based on CentOS and
Xfce4.                  2                    [OK]
docker.io   docker.io/blacklabelops/centos            CentOS Base Image!
Built and Updates
Daily!                                                  
1                    [OK]
docker.io   docker.io/darksheer/centos                Base Centos Image
— Updated
hourly                                                          
1                    [OK]
docker.io   docker.io/lighthopper/orientdb-centos     A Dockerfile for
creating an OrientDB image on top of the official CentOS
distribution.       1                    [OK]
docker.io   docker.io/timhughes/centos                Centos with
systemd installed and
running                                                    
1                    [OK]
docker.io   docker.io/yajo/centos-epel                CentOS with EPEL
and fully
updated                                                           
1                    [OK]
docker.io   docker.io/ericuni/centos                  centos
dev                                                                                   
0                    [OK]
docker.io   docker.io/grayzone/centos                 auto build for
centos.                                                                       
0                    [OK]
docker.io   docker.io/grossws/centos                  CentOS 6 and 7
base images with gosu and
locales                                             
0                    [OK]
docker.io   docker.io/januswel/centos                 yum update-ed
CentOS
image                                                                   
0                    [OK]
docker.io   docker.io/jsmigel/centos-epel             Docker base image
of CentOS w/ EPEL
installed                                                
0                    [OK]
docker.io   docker.io/kz8s/centos                     Official CentOS
plus
epel-release                                                            
0                    [OK]
docker.io   docker.io/labengine/centos                Centos image
base                                                                            
0                    [OK]
docker.io   docker.io/repositoryjp/centos             Docker Image for
CentOS.                                                                     
0                    [OK]
docker.io   docker.io/ustclug/centos                   USTC
centos               

下边须求的事物后,就足以用下边包车型地铁下令起首下载了。

镜像都以安分守己用户名/镜像名的不二诀要来积攒的。有壹组比较奇特的镜像,比方ubuntu那类基础镜像,经过法定的认证,值得信任,能够直接用镜像名来检索到。

[root@kvm1 tmp]# docker pull centos/mariadb55-centos7
Using default tag: latest
Trying to pull repository docker.io/centos/mariadb55-centos7 … latest:
Pulling from centos/mariadb55-centos7
1544084fad81: Pull complete
ddca430e683e: Downloading
[=============>                                     ] 19.44
MB/70.54 MB
bb35b9816560: Download complete
ddca430e683e: Pull complete
bb35b9816560: Pull complete
000ef0017d51: Pull complete
02b68f50c545: Pull complete
699ae6f1afb0: Pull complete
bb36ed4c0771: Pull complete
509e402b8043: Pull complete
5510bcbd751b: Pull complete
c65b7f76a8c0: Pull complete
d5bf20ab0e00: Pull complete
4e6bcf53b594: Pull complete
d480ffa2a79e: Pull complete
1cca63c752fe: Pull complete
b8476e51b045: Pull complete
b9232fb50895: Pull complete
56aa3ea11826: Pull complete
18fe7a620d97: Pull complete
Digest:
sha256:96bf01600a6b0c43eebd435eb863468a42816cb3a08d747d79e3e5d4dfd69df5
Status: Downloaded newer image for
docker.io/centos/mariadb55-centos7:latest

[root@kvm1 tmp]#

[root@kvm2 docker]# docker pull httpd
Using default tag: latest
Trying to pull repository docker.io/library/httpd … latest: Pulling
from library/httpd
23286f48d129: Pull complete
cbee5247e891: Pull complete
b88cfb2ab04b: Pull complete
f6f65ab94dc8: Pull complete
622e17bfb07d: Pull complete
c400bf2459b2: Pull complete
8c87d07c0fd8: Pull complete
b02f86f012c3: Pull complete
fade6d358f5e: Pull complete
2882c5b19e6a: Pull complete
9fce1c51710f: Pull complete
6ff460a5471f: Pull complete
6bce6ad2c6a9: Pull complete
Digest:
sha256:c89a26acb0edf2f5ef196db39837f3fc2a323ba149f966f7dbb0f0ad659cb4e1
Status: Downloaded newer image for docker.io/httpd:latest

[root@kvm2 ~]# docker run -it httpd bash
Usage of loopback devices is strongly discouraged for production use.
Either use `–storage-opt dm.thinpooldev` or use `–storage-opt
dm.no_warn_on_loop_devices=true` to suppress this warning.
root@e392fae6a6bd:/usr/local/apache2#

 

docker
run的授命参数,映射容器端口80到主机端口807陆,那样之后就足以用浏览器访问宿主机的ip+807陆
[root@kvm2 ff]# docker run -p 8076:80 -d -it httpd
27df118645f56d32cef13021150e484bb0737ce12c388414286e621035acb760
Usage of loopback devices is strongly discouraged for production use.
Either use `–storage-opt dm.thinpooldev` or use `–storage-opt
dm.no_warn_on_loop_devices=true` to suppress this warning.

To mount a host directory(/var/db) as a container volume(/data1)
docker run -v /var/db:/data1 -it httpd bash

 

镜像唯有贰个,但是容器有n个,每一趟运转都会生成3个比不上的。
[root@kvm2 ff]# docker ps -a
CONTAINER ID        IMAGE               COMMAND              
CREATED             STATUS                         
PORTS                  NAMES
dc8d8dce5ad9        httpd               “bash”                2 minutes
ago       Exited (0) About a minute ago                         
clever_sammet
27df118645f5        httpd               “httpd-foreground”    14 minutes
ago      Up 14 minutes                   0.0.0.0:8076->80/tcp  
thirsty_jang
6208f9ef6253        httpd               “httpd-foreground”    21 minutes
ago      Exited (0) 16 minutes ago                             
distracted_varahamihira
48987af82c5a        httpd               “bash”                24 minutes
ago      Exited (0) 23 minutes ago                             
reverent_hawking
58769180232c        httpd               “bash”                24 minutes
ago      Exited (0) 24 minutes ago                             
cocky_shaw
de3a82a9fddd        httpd               “httpd-foreground”    38 minutes
ago      Up 26 minutes                   80/tcp                
condescending_wilson
32101274af20        httpd               “bash”                40 minutes
ago      Exited (127) 39 minutes ago                           
focused_khorana
788c6fa29a70        httpd               “/usr/sbin/sshd -D”   40 minutes
ago      Created                                               
compassionate_meitner
e392fae6a6bd        httpd               “bash”                50 minutes
ago      Exited (0) 41 minutes ago                             
nostalgic_nobel
110dca752a67        httpd               “httpd-foreground”    50 minutes
ago      Exited (0) 50 minutes ago                             
compassionate_mestorf
7dc69d4edbcc        httpd               “httpd-foreground”    About an
hour ago   Exited (0) 58 minutes ago                             
gloomy_jang
9cdb405e0e0b        httpd               “httpd-foreground”    About an
hour ago   Exited (0) About an hour ago                          
adoring_fermi

[root@kvm2 ~]# docker ps -l
CONTAINER ID        IMAGE               COMMAND             
CREATED             STATUS                      PORTS              
NAMES
7dc69d4edbcc        httpd               “httpd-foreground”   12 minutes
ago      Exited (0) 11 minutes ago                       gloomy_jang
[root@kvm2 ~]# docker start 7dc69d4edbcc
7dc69d4edbcc

 

[root@kvm2 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                   NAMES
d3eae263c005        d6d9ec2e67f1        "supervisord -n"    17 hours ago        Up 3 seconds        22/tcp, 443/tcp, 0.0.0.0:8075->80/tcp   backstabbing_booth

[root@kvm2 ~]# docker exec d3e ls /var/www/html
phpinfo.php
[root@kvm2 ~]# cat co.php
<?php
echo "今天是 " . date("Y/m/d") . "<br>";
echo "今天是 " . date("Y.m.d") . "<br>";
echo "今天是 " . date("Y-m-d") . "<br>";
echo "今天是 " . date("l");
?>
[root@kvm2 ~]# docker cp co.php d3eae263c005cb34c74b4bceb834eb1e08a341a8c56d3563e026400ac0eb3764:/var/www/html/
[root@kvm2 ~]# docker exec d3e ls /var/www/html
co.php
phpinfo.php
只要复制进去,即刻生效,即使docker stop d3e,然后再docker start d3e也还是生效的

然后浏览器访问下面的地址返回是正常的。
http://192.168.1.22:8075/co.php

提交的作用是以刚才修改后的容器为蓝本,重新生成一个本地镜像
[root@kvm2 ~]# docker commit d3eae263c005cb34c74b4bceb834eb1e08a341a8c56d3563e026400ac0eb3764 lamp
c11ac41e64b6bdc85edac4ce57d786d3622d7d75b5d36651a7c0120d8ced3e54
[root@kvm2 ~]# docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
lamp                              latest              c11ac41e64b6        7 seconds ago       554.1 MB
nickistre/centos-lamp             latest              4f5630df2cde        22 minutes ago      554.1 MB
<none>                            <none>              241befbcd605        26 minutes ago      554.1 MB
<none>                            <none>              915e007c5e90        17 hours ago        554.1 MB
docker.io/httpd                   latest              6bce6ad2c6a9        8 days ago          198.5 MB
docker.io/nickistre/centos-lamp   latest              d6d9ec2e67f1        4 weeks ago         538.4 MB
<none>                            <none>              39843ad887c7        14 months ago       0 B

 1091  docker run -d -p 8654:80 lamp
 1092  docker ps
 1093  docker port 0bc
 1094  docker exec 0bc ls /var/www/html


[root@kvm2 ~]# docker run -it lamp bash
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
[root@60b5f3dd1074 /]# passwd
Changing password for user root.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@60b5f3dd1074 /]# exit
exit

 

[root@kvm2 ~]# docker run httpd
Usage of loopback devices is strongly discouraged for production use.
Either use `–storage-opt dm.thinpooldev` or use `–storage-opt
dm.no_warn_on_loop_devices=true` to suppress this warning.
AH00558: httpd: Could not reliably determine the server’s fully
qualified domain name, using 172.17.0.3. Set the ‘ServerName’ directive
globally to suppress this message
AH00558: httpd: Could not reliably determine the server’s fully
qualified domain name, using 172.17.0.3. Set the ‘ServerName’ directive
globally to suppress this message
[Wed Jun 15 08:22:23.630259 2016] [mpm_event:notice] [pid 1:tid
140015674001280] AH00489: Apache/2.4.20 (Unix) configured — resuming
normal operations
[Wed Jun 15 08:22:23.630341 2016] [core:notice] [pid 1:tid
140015674001280] AH00094: Command line: ‘httpd -D FOREGROUND’

运行二回run,就能扭转一个新的器皿,然后就可以对那些容器举办start,stop等操作

[root@kvm2 ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             
CREATED             STATUS              PORTS               NAMES
588dd2b3b8a1        httpd               “httpd-foreground”   2 minutes
ago       Up 2 minutes        80/tcp              fervent_brown
63deabe2d1a8        httpd               “httpd-foreground”   7 minutes
ago       Up 2 minutes        80/tcp              angry_bohr

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有