Docker仓库管理

一.简介

仓库是一个存放镜像的地方

二.基本操作

1.docker research来搜寻官方镜像,以ubuntu为例

root@node4:~/webNginx# docker search ubuntu
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                            Ubuntu is a Debian-based Linux operating s...   5264      [OK]       
ubuntu-upstart                    Upstart is an event-based replacement for ...   69        [OK]       
rastasheep/ubuntu-sshd            Dockerized SSH service, built on top of of...   61                   [OK]
ubuntu-debootstrap                debootstrap --variant=minbase --components...   27        [OK]       
torusware/speedus-ubuntu          Always updated official Ubuntu docker imag...   27                   [OK]
nickistre/ubuntu-lamp             LAMP server on Ubuntu                           13                   [OK]
nuagebec/ubuntu                   Simple always updated Ubuntu docker images...   12                   [OK]
nickistre/ubuntu-lamp-wordpress   LAMP on Ubuntu with wp-cli installed            8                    [OK]
nimmis/ubuntu                     This is a docker images different LTS vers...   6                    [OK]
maxexcloo/ubuntu                  Base image built on Ubuntu with init, Supe...   2                    [OK]
admiringworm/ubuntu               Base ubuntu images based on the official u...   1                    [OK]
jordi/ubuntu                      Ubuntu Base Image                               1                    [OK]
darksheer/ubuntu                  Base Ubuntu Image -- Updated hourly             1                    [OK]
labengine/ubuntu                  Images base ubuntu                              0                    [OK]
datenbetrieb/ubuntu               custom flavor of the official ubuntu base ...   0                    [OK]
vcatechnology/ubuntu              A Ubuntu image that is updated daily            0                    [OK]
teamrock/ubuntu                   TeamRock's Ubuntu image configured with AW...   0                    [OK]
lynxtp/ubuntu                     https://github.com/lynxtp/docker-ubuntu         0                    [OK]
ustclug/ubuntu                    ubuntu image for docker with USTC mirror        0                    [OK]
widerplan/ubuntu                  Our basic Ubuntu images.                        0                    [OK]
esycat/ubuntu                     Ubuntu LTS                                      0                    [OK]
webhippie/ubuntu                  Docker images for ubuntu                        0                    [OK]
konstruktoid/ubuntu               Ubuntu base image                               0                    [OK]
smartentry/ubuntu                 ubuntu with smartentry                          0                    [OK]
uvatbc/ubuntu                     Ubuntu images with unprivileged user            0                    [OK]
root@node4:~/webNginx#
上面这些镜像都可以通过docker pull来拉下来

三.私有仓库

构建私有仓库的工具docker-registry

1.安装运行docker-registry工具

root@node4:~/webNginx# docker run -d -p 5000:5000 registry

此处如果端口被占用的解除端口占用才能用

查看端口是否占用命令netstat -a | grep 5000

解除端口命令

=====================================================================================

root@node4:~# lsof -i:5000
COMMAND     PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
docker-pr 23421 root    4u  IPv6 9741894      0t0  TCP *:5000 (LISTEN)
root@node4:~# kill -9 23421
=====================================================================================

2.使用registry镜像来启动本地私有仓库,例如陪Amazon s3服务器

=====================================================================================

root@node4:~/webNginx# 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
=====================================================================================

=====================================================================================

sudo docker run -d -p 5000:5000 -v /home/user/registry-conf:/registry-conf -e DOCKER_REGISTRY_CONFIG=/registry-conf/config.yml registry

=====================================================================================

3.默认情况下,仓库会被创建在tmp/registry下,但我们能通过-v参数指定镜像存储目录

=====================================================================================

sudo docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry

=====================================================================================

4.安装Ubuntu和CentOS等发行版

a.Ubuntu

apt-get install -y build-essential python-dev libevent-dev python-pip liblzma-dev

pip install docker-registry

b.CentOS

sudo yum install -y python-devel libevent-devel python-pip gcc xz-devel
sudo python-pip install docker-registry

c.从docker-registry中下载源码进行安装

=====================================================================================

sudo apt-get install build-essential python-dev libevent-dev python-pip libssl-dev liblzma-dev libffi-dev
 git clone https://github.com/docker/docker-registry.git
 cd docker-registry
 sudo python setup.py install

======================================================================================

5.修改配置文件,主要修改 dev 模板段的 storage_path 到本地的存储仓库的路径。
 cp config/config_sample.yml config/config.yml
6.后启动 Web 服务。
sudo gunicorn -c contrib/gunicorn.py docker_registry.wsgi:application或者sudo gunicorn --access-logfile - --error-logfile - -k gevent -b 0.0.0.0:5000 -w 4 --max-requests 100 docker_registry.wsgi:application
此时使用 curl 访问本地的 5000 端口,看到输出 docker-registry 的版本信息说明运行成功。



你可能感兴趣的:(Docker)