docker

2018-12-08  本文已影响0人  陈靖_7314

3 Software installation simplified

three main ways to install Docker images:

3.1 Identifying software

docker使用镜像来创建容器,镜像其实就是一个文件,这些文件包括用于创建容器的和关于镜像的元文件,这些元文件包括镜像间的关系,镜像的命令历史,暴露的端口,卷的定义等。
images都有唯一标识,原生的标示比较复杂。每次对镜像的修改都会使唯一标识改变,标识比较难用,我们使用仓库替代。

3.1.1 What is a repository

仓库就是存放镜像的地方,仓库的名字类似于URL。仓库名字由3个部分组成,image的位置、用户名、剪短的名字。
例如:


image.png

3.2 Finding and installing software

有许多的Docker indexes ,默认的是Docker Hub。Docker Hub is a registry and index with a website run by Docker Inc. (Docker Hub是一个注册表和索引,其中包含由Docker Inc运营的网站)。

3.2.1 Docker Hub from the command line

There are two ways that an image author can publish their images on Docker Hub:

docker search postgres

3.2.2 Docker Hub from the website

docker hub 网址
There are three other ways to install software:

3.2.2 Using alternative registries

使用一个可选的registry,不需要额外的配置,只需要列出resistry的地址。下面这个命令就是从一个制定的仓库中下载镜像的例子。

docker pull quay.io/dockerinaction/ch3_hello_registry:latest

有的时候,可能需要进行权限的认证,这要参考所选仓库的配置信息,进行权限认证。
The full pattern is as follows:

[REGISTRYHOST/][USERNAME/]NAME[:TAG]

3.2.4 Images as files

先拥有一个镜像,然后将镜像打包另存为文件,再删除进行,从文件中进行恢复。


image.png
docker pull busybox:latest
docker save -o myfile.tar busybox:latest
docker rmi busybox
docker load –i myfile.tar

You can use any filename you want. If you omit the –o flag,the resulting file will be streamed to the terminal.

上一篇 下一篇

猜你喜欢

热点阅读