github.com/samsalisbury/distribution@v2.2.1-0.20151123021722-54f974340220+incompatible/contrib/compose/README.md (about) 1 # Docker Compose V1 + V2 registry 2 3 This compose configuration configures a `v1` and `v2` registry behind an `nginx` 4 proxy. By default, you can access the combined registry at `localhost:5000`. 5 6 The configuration does not support pushing images to `v2` and pulling from `v1`. 7 If a `docker` client has a version less than 1.6, Nginx will route its requests 8 to the 1.0 registry. Requests from newer clients will route to the 2.0 registry. 9 10 ### Install Docker Compose 11 12 1. Open a new terminal on the host with your `distribution` source. 13 14 2. Get the `docker-compose` binary. 15 16 $ sudo wget https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` -O /usr/local/bin/docker-compose 17 18 This command installs the binary in the `/usr/local/bin` directory. 19 20 3. Add executable permissions to the binary. 21 22 $ sudo chmod +x /usr/local/bin/docker-compose 23 24 ## Build and run with Compose 25 26 1. In your terminal, navigate to the `distribution/contrib/compose` directory 27 28 This directory includes a single `docker-compose.yml` configuration. 29 30 nginx: 31 build: "nginx" 32 ports: 33 - "5000:5000" 34 links: 35 - registryv1:registryv1 36 - registryv2:registryv2 37 registryv1: 38 image: registry 39 ports: 40 - "5000" 41 registryv2: 42 build: "../../" 43 ports: 44 - "5000" 45 46 This configuration builds a new `nginx` image as specified by the 47 `nginx/Dockerfile` file. The 1.0 registry comes from Docker's official 48 public image. Finally, the registry 2.0 image is built from the 49 `distribution/Dockerfile` you've used previously. 50 51 2. Get a registry 1.0 image. 52 53 $ docker pull registry:0.9.1 54 55 The Compose configuration looks for this image locally. If you don't do this 56 step, later steps can fail. 57 58 3. Build `nginx`, the registry 2.0 image, and 59 60 $ docker-compose build 61 registryv1 uses an image, skipping 62 Building registryv2... 63 Step 0 : FROM golang:1.4 64 65 ... 66 67 Removing intermediate container 9f5f5068c3f3 68 Step 4 : COPY docker-registry-v2.conf /etc/nginx/docker-registry-v2.conf 69 ---> 74acc70fa106 70 Removing intermediate container edb84c2b40cb 71 Successfully built 74acc70fa106 72 73 The commmand outputs its progress until it completes. 74 75 4. Start your configuration with compose. 76 77 $ docker-compose up 78 Recreating compose_registryv1_1... 79 Recreating compose_registryv2_1... 80 Recreating compose_nginx_1... 81 Attaching to compose_registryv1_1, compose_registryv2_1, compose_nginx_1 82 ... 83 84 85 5. In another terminal, display the running configuration. 86 87 $ docker ps 88 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 89 a81ad2557702 compose_nginx:latest "nginx -g 'daemon of 8 minutes ago Up 8 minutes 80/tcp, 443/tcp, 0.0.0.0:5000->5000/tcp compose_nginx_1 90 0618437450dd compose_registryv2:latest "registry cmd/regist 8 minutes ago Up 8 minutes 0.0.0.0:32777->5000/tcp compose_registryv2_1 91 aa82b1ed8e61 registry:latest "docker-registry" 8 minutes ago Up 8 minutes 0.0.0.0:32776->5000/tcp compose_registryv1_1 92 93 ### Explore a bit 94 95 1. Check for TLS on your `nginx` server. 96 97 $ curl -v https://localhost:5000 98 * Rebuilt URL to: https://localhost:5000/ 99 * Hostname was NOT found in DNS cache 100 * Trying 127.0.0.1... 101 * Connected to localhost (127.0.0.1) port 5000 (#0) 102 * successfully set certificate verify locations: 103 * CAfile: none 104 CApath: /etc/ssl/certs 105 * SSLv3, TLS handshake, Client hello (1): 106 * SSLv3, TLS handshake, Server hello (2): 107 * SSLv3, TLS handshake, CERT (11): 108 * SSLv3, TLS alert, Server hello (2): 109 * SSL certificate problem: self signed certificate 110 * Closing connection 0 111 curl: (60) SSL certificate problem: self signed certificate 112 More details here: http://curl.haxx.se/docs/sslcerts.html 113 114 2. Tag the `v1` registry image. 115 116 $ docker tag registry:latest localhost:5000/registry_one:latest 117 118 2. Push it to the localhost. 119 120 $ docker push localhost:5000/registry_one:latest 121 122 If you are using the 1.6 Docker client, this pushes the image the `v2 `registry. 123 124 4. Use `curl` to list the image in the registry. 125 126 $ curl -v -X GET http://localhost:32777/v2/registry1/tags/list 127 * Hostname was NOT found in DNS cache 128 * Trying 127.0.0.1... 129 * Connected to localhost (127.0.0.1) port 32777 (#0) 130 > GET /v2/registry1/tags/list HTTP/1.1 131 > User-Agent: curl/7.36.0 132 > Host: localhost:32777 133 > Accept: */* 134 > 135 < HTTP/1.1 200 OK 136 < Content-Type: application/json; charset=utf-8 137 < Docker-Distribution-Api-Version: registry/2.0 138 < Date: Tue, 14 Apr 2015 22:34:13 GMT 139 < Content-Length: 39 140 < 141 {"name":"registry1","tags":["latest"]} 142 * Connection #0 to host localhost left intact 143 144 This example refers to the specific port assigned to the 2.0 registry. You saw 145 this port earlier, when you used `docker ps` to show your running containers. 146 147