Remove the local repo case, add its content into the image and repository sections
parent
71bcec05b7
commit
2a60b4ce7e
|
@ -28,7 +28,7 @@
|
|||
* [删除](container/rm.md)
|
||||
* [仓库](repository/README.md)
|
||||
* [Docker Hub](repository/dockerhub.md)
|
||||
* [仓库管理](repository/management.md)
|
||||
* [私有仓库](repository/management.md)
|
||||
* [数据管理](data_management/README.md)
|
||||
* [数据卷](data_management/volume.md)
|
||||
* [数据卷容器](data_management/container.md)
|
||||
|
@ -47,7 +47,6 @@
|
|||
* [编辑网络配置文件](advanced_network/config_file.md)
|
||||
* [实例:创建一个点到点连接](advanced_network/ptp.md)
|
||||
* [实战案例](cases/README.md)
|
||||
* [部署本地仓库](cases/local_repo.md)
|
||||
* [使用 Supervisor来管理进程](cases/supervisor.md)
|
||||
* [创建tomcat/weblogic集群](cases/tomcat.md)
|
||||
* [多台物理主机之间的容器互联](cases/container_connect.md)
|
||||
|
@ -59,6 +58,7 @@
|
|||
* [内核能力机制](security/kernel_capability.md)
|
||||
* [其它安全特性](security/other_feature.md)
|
||||
* [总结](security/summary.md)
|
||||
* [Dockerfile配置](dockerfile/README.md)
|
||||
* [底层实现](underly/README.md)
|
||||
* [基本架构](underly/arch.md)
|
||||
* [名字空间](underly/namespace.md)
|
||||
|
@ -66,7 +66,6 @@
|
|||
* [Union文件系统](underly/ufs.md)
|
||||
* [容器格式](underly/container_format.md)
|
||||
* [网络](underly/network.md)
|
||||
* [Dockerfile](dockerfile/README.md)
|
||||
* [附录一:命令查询](command/README.md)
|
||||
* [附录二:资源链接](resources/README.md)
|
||||
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
##部署本地仓库
|
||||
有时候使用Docker Hub这样的公共仓库可能不方便,用户可以创建一个本地仓库供私人使用。
|
||||
|
||||
本节介绍如何创建部署本地仓库。
|
||||
|
||||
###创建一个镜像
|
||||
创建镜像有很多方法,用户可以从Docker Hub获取一个,也可以利用本地文件系统创建一个。
|
||||
|
||||
要从本地文件系统导入一个镜像,可以使用openvz(容器虚拟化的先锋技术)的模板来创建:
|
||||
openvz的模板下载地址为http://openvz.org/Download/templates/precreated。
|
||||
|
||||
比如:先下载了一个ubuntu14.04的镜像,之后使用以下命令导入:
|
||||
```
|
||||
sudo cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04
|
||||
```
|
||||
然后查看新导入的镜像。
|
||||
```
|
||||
docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu 14.04 05ac7c0b9383 17 seconds ago 215.5 MB
|
||||
```
|
||||
|
||||
|
||||
###创建私有仓库
|
||||
创建私有仓库可以使用`docker-registry`工具。
|
||||
#### 系统自带
|
||||
在安装了Docker后,系统中就自带了`docker-registry`工具,可以运行
|
||||
```
|
||||
docker run -p 5000:5000 registry
|
||||
```
|
||||
这将使用官方的registry镜像来启动本地的私有仓库。可以通过指定参数来配置私有仓库位置,例如配置镜像存储到Amazon的S3服务。
|
||||
```
|
||||
docker run \
|
||||
-e SETTINGS_FLAVOR=s3 \
|
||||
-e AWS_BUCKET=acme-docker \
|
||||
-e STORAGE_PATH=/registry \
|
||||
-e AWS_KEY=AKIAHSHB43HS3J92MXZ \
|
||||
-e AWS_SECRET=xdDowwlK7TJajV1Y7EoOZrmuPEJlHYcNP2k4j49T \
|
||||
-e SEARCH_BACKEND=sqlalchemy \
|
||||
-p 5000:5000 \
|
||||
registry
|
||||
````
|
||||
|
||||
#### 源码安装
|
||||
从[docker-registry](https://github.com/docker/docker-registry)项目下载源码并安装。
|
||||
```
|
||||
$ sudo apt-get install build-essential python-dev libevent-dev python-pip libssl-dev liblzma-dev libffi-dev
|
||||
$ sudo pip install .
|
||||
```
|
||||
`config/config_sample.yml`文件是配置文件。
|
||||
|
||||
###在私有仓库上传、下载、搜索镜像
|
||||
创建好私有仓库之后,就可以使用`docker tag`来标记一个镜像,然后推送它到仓库,别的机器上就可以下载下来了。例如私有仓库地址为`192.168.7.26:5000`。
|
||||
|
||||
先在本机查看已有的镜像。
|
||||
```
|
||||
$ sudo docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
||||
|
||||
使用`docker tag`将ba58这个镜像标记为`192.168.7.26:5000/test`(格式为`[REGISTRYHOST/][USERNAME/]NAME[:TAG]`)。
|
||||
```
|
||||
$ sudo docker tag ba58 192.168.7.26:5000/test
|
||||
root ~ # docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
||||
使用`docker push`上传标记的镜像。
|
||||
```
|
||||
$ sudo docker push 192.168.7.26:5000/test
|
||||
The push refers to a repository [192.168.7.26:5000/test] (len: 1)
|
||||
Sending image list
|
||||
Pushing repository 192.168.7.26:5000/test (1 tags)
|
||||
Image 511136ea3c5a already pushed, skipping
|
||||
Image 9bad880da3d2 already pushed, skipping
|
||||
Image 25f11f5fb0cb already pushed, skipping
|
||||
Image ebc34468f71d already pushed, skipping
|
||||
Image 2318d26665ef already pushed, skipping
|
||||
Image ba5877dc9bec already pushed, skipping
|
||||
Pushing tag for rev [ba5877dc9bec] on {http://192.168.7.26:5000/v1/repositories/test/tags/latest}
|
||||
```
|
||||
用curl查看仓库中的镜像。
|
||||
```
|
||||
$ curl http://192.168.7.26:5000/v1/search
|
||||
{"num_results": 7, "query": "", "results": [{"description": "", "name": "library/miaxis_j2ee"}, {"description": "", "name": "library/tomcat"}, {"description": "", "name": "library/ubuntu"}, {"description": "", "name": "library/ubuntu_office"}, {"description": "", "name": "library/desktop_ubu"}, {"description": "", "name": "dockerfile/ubuntu"}, {"description": "", "name": "library/test"}]}
|
||||
```
|
||||
这里可以看到`{"description": "", "name": "library/test"}`,表明镜像已经被成功上传了。
|
||||
|
||||
现在可以到另外一台机器去下载这个镜像
|
||||
```
|
||||
$ sudo docker pull 192.168.7.26:5000/test
|
||||
Pulling repository 192.168.7.26:5000/test
|
||||
ba5877dc9bec: Download complete
|
||||
511136ea3c5a: Download complete
|
||||
9bad880da3d2: Download complete
|
||||
25f11f5fb0cb: Download complete
|
||||
ebc34468f71d: Download complete
|
||||
2318d26665ef: Download complete
|
||||
$ sudo docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
|
@ -1,8 +1,8 @@
|
|||
##创建镜像
|
||||
别人的镜像虽然好,但不一定适合我们。
|
||||
我们可以对这些镜像做一些修改,有2个方法:利用现成的镜像进行修改或者利用dockerfile创建。
|
||||
|
||||
###使用docker commit 来扩展一个镜像
|
||||
创建镜像有很多方法,用户可以从Docker Hub获取已有镜像并更新,也可以利用本地文件系统创建一个。
|
||||
|
||||
### 修改已有镜像
|
||||
先使用下载的镜像启动容器。
|
||||
```
|
||||
$ sudo docker run -t -i training/sinatra /bin/bash
|
||||
|
@ -112,16 +112,14 @@ ADD myApp /var/www
|
|||
EXPOSE 80
|
||||
# the command to run
|
||||
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
|
||||
|
||||
```
|
||||
|
||||
现在可以利用新创建的镜像来启动一个容器。
|
||||
```
|
||||
$ sudo docker run -t -i ouruser/sinatra:v2 /bin/bash
|
||||
root@8196968dac35:/#
|
||||
|
||||
```
|
||||
还可以用tag命令来修改镜像的tag。
|
||||
还可以用`docker tag`命令来修改镜像的标签。
|
||||
```
|
||||
$ sudo docker tag 5db5f8471261 ouruser/sinatra:devel
|
||||
$ sudo docker images ouruser/sinatra
|
||||
|
@ -131,4 +129,19 @@ ouruser/sinatra devel 5db5f8471261 11 hours ago 446.7 MB
|
|||
ouruser/sinatra v2 5db5f8471261 11 hours ago 446.7 MB
|
||||
```
|
||||
|
||||
更多用法,请参考dockerfile章节。
|
||||
*注:更多用法,请参考dockerfile章节。
|
||||
|
||||
### 从本地文件系统导入
|
||||
要从本地文件系统导入一个镜像,可以使用openvz(容器虚拟化的先锋技术)的模板来创建:
|
||||
openvz的模板下载地址为http://openvz.org/Download/templates/precreated。
|
||||
|
||||
比如:先下载了一个ubuntu14.04的镜像,之后使用以下命令导入:
|
||||
```
|
||||
sudo cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04
|
||||
```
|
||||
然后查看新导入的镜像。
|
||||
```
|
||||
docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu 14.04 05ac7c0b9383 17 seconds ago 215.5 MB
|
||||
```
|
||||
|
|
|
@ -17,7 +17,6 @@ subwiz/sinatra
|
|||
bmorearty/sinatra 0
|
||||
```
|
||||
|
||||
|
||||
可以看到返回了很多包含sinatra的镜像。其中包括镜像名字、描述、星级(表示该镜像的受欢迎程度)、是否官方创建、是否自动创建。
|
||||
官方的镜像是由stackbrew项目组创建和维护的,automated 资源允许用户验证镜像的来源和内容。
|
||||
|
||||
|
|
|
@ -1 +1,97 @@
|
|||
##仓库管理
|
||||
##私有仓库
|
||||
|
||||
有时候使用Docker Hub这样的公共仓库可能不方便,用户可以创建一个本地仓库供私人使用。
|
||||
|
||||
本节介绍如何使用本地仓库。
|
||||
|
||||
docker-registry是官方提供的工具,可以用于构建私有的镜像仓库。
|
||||
###安装docker-registry
|
||||
#### 系统自带
|
||||
在安装了Docker后,系统中就自带了`docker-registry`工具,可以运行
|
||||
```
|
||||
docker run -p 5000:5000 registry
|
||||
```
|
||||
这将使用官方的registry镜像来启动本地的私有仓库。可以通过指定参数来配置私有仓库位置,例如配置镜像存储到Amazon的S3服务。
|
||||
```
|
||||
docker run \
|
||||
-e SETTINGS_FLAVOR=s3 \
|
||||
-e AWS_BUCKET=acme-docker \
|
||||
-e STORAGE_PATH=/registry \
|
||||
-e AWS_KEY=AKIAHSHB43HS3J92MXZ \
|
||||
-e AWS_SECRET=xdDowwlK7TJajV1Y7EoOZrmuPEJlHYcNP2k4j49T \
|
||||
-e SEARCH_BACKEND=sqlalchemy \
|
||||
-p 5000:5000 \
|
||||
registry
|
||||
````
|
||||
|
||||
#### 源码安装
|
||||
从[docker-registry](https://github.com/docker/docker-registry)项目下载源码安装。
|
||||
```
|
||||
$ sudo apt-get install build-essential python-dev libevent-dev python-pip libssl-dev liblzma-dev libffi-dev
|
||||
$ sudo pip install .
|
||||
```
|
||||
然后修改配置文件,主要修改`storage_path`到本地的存储仓库的路径,之后启动Web服务。
|
||||
```
|
||||
$ cp config/config_sample.yml config/config.yml
|
||||
$ #do some change to config.yml
|
||||
$ sudo /usr/bin/gunicorn --debug -k gevent -b 0.0.0.0:5000 -w 8 docker_registry.wsgi:application
|
||||
```
|
||||
此时使用访问本地的5000端口,看到输出docker-registry的版本信息说明运行成功。
|
||||
|
||||
*注:`config/config_sample.yml`文件是示例配置文件。
|
||||
|
||||
###在私有仓库上传、下载、搜索镜像
|
||||
创建好私有仓库之后,就可以使用`docker tag`来标记一个镜像,然后推送它到仓库,别的机器上就可以下载下来了。例如私有仓库地址为`192.168.7.26:5000`。
|
||||
|
||||
先在本机查看已有的镜像。
|
||||
```
|
||||
$ sudo docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
||||
|
||||
使用`docker tag`将ba58这个镜像标记为`192.168.7.26:5000/test`(格式为`docker tag IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]`)。
|
||||
```
|
||||
$ sudo docker tag ba58 192.168.7.26:5000/test
|
||||
root ~ # docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
ubuntu 14.04 ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
ubuntu latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
||||
使用`docker push`上传标记的镜像。
|
||||
```
|
||||
$ sudo docker push 192.168.7.26:5000/test
|
||||
The push refers to a repository [192.168.7.26:5000/test] (len: 1)
|
||||
Sending image list
|
||||
Pushing repository 192.168.7.26:5000/test (1 tags)
|
||||
Image 511136ea3c5a already pushed, skipping
|
||||
Image 9bad880da3d2 already pushed, skipping
|
||||
Image 25f11f5fb0cb already pushed, skipping
|
||||
Image ebc34468f71d already pushed, skipping
|
||||
Image 2318d26665ef already pushed, skipping
|
||||
Image ba5877dc9bec already pushed, skipping
|
||||
Pushing tag for rev [ba5877dc9bec] on {http://192.168.7.26:5000/v1/repositories/test/tags/latest}
|
||||
```
|
||||
用curl查看仓库中的镜像。
|
||||
```
|
||||
$ curl http://192.168.7.26:5000/v1/search
|
||||
{"num_results": 7, "query": "", "results": [{"description": "", "name": "library/miaxis_j2ee"}, {"description": "", "name": "library/tomcat"}, {"description": "", "name": "library/ubuntu"}, {"description": "", "name": "library/ubuntu_office"}, {"description": "", "name": "library/desktop_ubu"}, {"description": "", "name": "dockerfile/ubuntu"}, {"description": "", "name": "library/test"}]}
|
||||
```
|
||||
这里可以看到`{"description": "", "name": "library/test"}`,表明镜像已经被成功上传了。
|
||||
|
||||
现在可以到另外一台机器去下载这个镜像
|
||||
```
|
||||
$ sudo docker pull 192.168.7.26:5000/test
|
||||
Pulling repository 192.168.7.26:5000/test
|
||||
ba5877dc9bec: Download complete
|
||||
511136ea3c5a: Download complete
|
||||
9bad880da3d2: Download complete
|
||||
25f11f5fb0cb: Download complete
|
||||
ebc34468f71d: Download complete
|
||||
2318d26665ef: Download complete
|
||||
$ sudo docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
192.168.7.26:5000/test latest ba5877dc9bec 6 weeks ago 192.7 MB
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue