Introduction to Docker and Registry

[Editor's Note] This article introduces Docker and Registry. The author said that Docker is an application hosting framework, and the highlight is to simplify application deployment and version control of application deployment. At the same time, the author introduces the installation of Docker Registry and a mirror project docker-registry-web that can browse the Registry through the web. 

Docker is an application hosting framework that deploys and manages applications through virtual machine-like containers, which in turn can create and control them through APIs. 

Docker allows you to package dependencies/servers and applications into a thin image that is layered on top of other images (like Ubuntu, or something special for your needs). Unlike virtual machines, although they are strictly isolated from programs in other systems using  LXC and  cgroups (a Linux concept mentioned in the previous article), they share the same resources with little additional overhead. When you start a virtual machine, you end up with a prompt or UI for installing or running applications. When you start an application container, you just run a script that starts the application and its dependencies, and that's it. You can run several virtual machines on a system, but you can run thousands of application containers. If you want streamlined distribution, consider using CoreOS at the system level to host your images. 

Another feature of Docker is version control. You can commit any changes made in the container as a new image. Of course, you can also use the same image (the image itself is immutable) to launch as many containers as you want. 

In the process of distributing images to other teams or companies, you may need to find a place to publish or locate your images outside of your current system. This can be achieved through the Registry. Although Docker provides public Docker Hub Registry , you may want a private registry for your own company or team. 

Since Docker's components/add-ons themselves are often distributed via Docker images, this example also shows how easy it is to start a Docker-based application (if you're not familiar with this before). You don't need to know anything about the client application other than the ports occupied by the service. In fact, you can start an image that other Docker images need (hereafter called a container), have Docker map random local ports to it, and then automatically forward the ports of the serving containers to the containers that depend on those services (via "  link " function). Start your Registry with a command

similar  to the example on the homepage of the Registry project :

$ docker run
     -e SETTINGS_FLAVOR=s3
     -e AWS_BUCKET=mybucket
     -e STORAGE_PATH=/registry
     -e AWS_KEY=myawskey
     -e AWS_SECRET=myawssecret
     -e SEARCH_BACKEND=sqlalchemy
     -p 5000:5000
     registry



This is mainly to set six environment variables for the application, save it on S3, and forward port 5000 of the host (local) system to port 5000 of the client (Registry). "registry" is the running image name (if it's owned by a user, it looks like "/"). If the image does not already exist locally, it will be located and pulled down. If not qualified with the registry prefix, it will be assumed to be on Docker Hub. 

In this example, we pull the Ubuntu image from the Hub and push it to our Registry. Notably, we qualify "push" and "pull" requests to our registry by prefixing the registry's hostname/port.

$ sudo docker pull ubuntu:14.04
$ sudo docker tag 826544226fdc yourregistry.net:5000/ubuntu
$ sudo docker push yourregistry.net:5000/ubuntu
$ sudo docker pull yourregistry.net:5000/ubuntu



The tag command reserves a new location in our registry for images given elsewhere. You can get its ID string in the local list. 

By default, the Registry only communicates directly with the Docker socket or manages it via REST. If you want to browse images more easily, install  the docker-registry-web project: 

$ docker run -p 8080:8080 -e REG1=http://:5000/v1/ atcol/docker-registry-ui



请记住,它需要与你的Registry实例联系,所以要确保你提供的registry主机名在docker-registry-web容器里可被解析。 

截图如下: 

Docker以及Registry介绍



docker-registry-web实际上是一个Java应用,然而它是个设计不佳的镜像(如果知道这点对你很重要的话)。 

最后,在你玩够Registry实例后,记得将它隐藏在Nginx代理之后,并添加认证(双向、HTTP等)。 

原文链接:Intro to Docker, and Private Image Registries(翻译:Sean 审校:林仁)

来自:http://dockerone.com/article/108

 

http://www.open-open.com/lib/view/open1420287708609.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326749218&siteId=291194637