Browse code

Major rearrange of the documentation.

Thatcher Peskens authored on 2013/05/10 09:05:20
Showing 23 changed files
... ...
@@ -44,7 +44,7 @@ clean:
44 44
 	-rm -rf $(BUILDDIR)/*
45 45
 
46 46
 docs:
47
-	-rm -rf $(BUILDDIR)/*
47
+	#-rm -rf $(BUILDDIR)/*
48 48
 	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/html
49 49
 	@echo
50 50
 	@echo "Build finished. The documentation pages are now in $(BUILDDIR)/html."
51 51
new file mode 100644
... ...
@@ -0,0 +1,16 @@
0
+:title: docker documentation
1
+:description: docker documentation
2
+:keywords:
3
+
4
+API's
5
+=============
6
+
7
+This following :
8
+
9
+.. toctree::
10
+  :maxdepth: 3
11
+
12
+  registry_api
13
+  index_search_api
14
+
15
+
0 16
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+:title: Docker Index documentation
1
+:description: Documentation for docker Index
2
+:keywords: docker, index, api
3
+
4
+
5
+=======================
6
+Docker Index Search API
7
+=======================
8
+
9
+Search
10
+------
11
+
12
+.. http:get:: /v1/search
13
+
14
+   Search the Index given a search term. It accepts :http:method:`get` only.
15
+
16
+   **Example request**:
17
+
18
+   .. sourcecode:: http
19
+
20
+      GET /v1/search?q=search_term HTTP/1.1
21
+      Host: example.com
22
+      Accept: application/json
23
+
24
+   **Example response**:
25
+
26
+   .. sourcecode:: http
27
+
28
+      HTTP/1.1 200 OK
29
+      Vary: Accept
30
+      Content-Type: application/json
31
+
32
+      {"query":"search_term",
33
+        "num_results": 2,
34
+        "results" : [
35
+           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
36
+           {"name": "base2", "description": "A base ubuntu64  image..."},
37
+         ]
38
+       }
39
+
40
+   :query q: what you want to search for
41
+   :statuscode 200: no error
42
+   :statuscode 500: server error
0 43
\ No newline at end of file
1 44
new file mode 100644
... ...
@@ -0,0 +1,473 @@
0
+:title: docker Registry documentation
1
+:description: Documentation for docker Registry and Registry API
2
+:keywords: docker, registry, api, index
3
+
4
+
5
+===================
6
+Docker Registry API
7
+===================
8
+
9
+.. contents:: Table of Contents
10
+
11
+1. The 3 roles
12
+===============
13
+
14
+1.1 Index
15
+---------
16
+
17
+The Index is responsible for centralizing information about:
18
+- User accounts
19
+- Checksums of the images
20
+- Public namespaces
21
+
22
+The Index has different components:
23
+- Web UI
24
+- Meta-data store (comments, stars, list public repositories)
25
+- Authentication service
26
+- Tokenization
27
+
28
+The index is authoritative for those information.
29
+
30
+We expect that there will be only one instance of the index, run and managed by dotCloud.
31
+
32
+1.2 Registry
33
+------------
34
+- It stores the images and the graph for a set of repositories
35
+- It does not have user accounts data
36
+- It has no notion of user accounts or authorization
37
+- It delegates authentication and authorization to the Index Auth service using tokens
38
+- It supports different storage backends (S3, cloud files, local FS)
39
+- It doesn’t have a local database
40
+- It will be open-sourced at some point
41
+
42
+We expect that there will be multiple registries out there. To help to grasp the context, here are some examples of registries:
43
+
44
+- **sponsor registry**: such a registry is provided by a third-party hosting infrastructure as a convenience for their customers and the docker community as a whole. Its costs are supported by the third party, but the management and operation of the registry are supported by dotCloud. It features read/write access, and delegates authentication and authorization to the Index.
45
+- **mirror registry**: such a registry is provided by a third-party hosting infrastructure but is targeted at their customers only. Some mechanism (unspecified to date) ensures that public images are pulled from a sponsor registry to the mirror registry, to make sure that the customers of the third-party provider can “docker pull” those images locally.
46
+- **vendor registry**: such a registry is provided by a software vendor, who wants to distribute docker images. It would be operated and managed by the vendor. Only users authorized by the vendor would be able to get write access. Some images would be public (accessible for anyone), others private (accessible only for authorized users). Authentication and authorization would be delegated to the Index. The goal of vendor registries is to let someone do “docker pull basho/riak1.3” and automatically push from the vendor registry (instead of a sponsor registry); i.e. get all the convenience of a sponsor registry, while retaining control on the asset distribution.
47
+- **private registry**: such a registry is located behind a firewall, or protected by an additional security layer (HTTP authorization, SSL client-side certificates, IP address authorization...). The registry is operated by a private entity, outside of dotCloud’s control. It can optionally delegate additional authorization to the Index, but it is not mandatory.
48
+
49
+.. note::
50
+
51
+    Mirror registries and private registries which do not use the Index don’t even need to run the registry code. They can be implemented by any kind of transport implementing HTTP GET and PUT. Read-only registries can be powered by a simple static HTTP server.
52
+
53
+.. note::
54
+
55
+    The latter implies that while HTTP is the protocol of choice for a registry, multiple schemes are possible (and in some cases, trivial):
56
+        - HTTP with GET (and PUT for read-write registries);
57
+        - local mount point;
58
+        - remote docker addressed through SSH.
59
+
60
+The latter would only require two new commands in docker, e.g. “registryget” and “registryput”, wrapping access to the local filesystem (and optionally doing consistency checks). Authentication and authorization are then delegated to SSH (e.g. with public keys).
61
+
62
+1.3 Docker
63
+----------
64
+
65
+On top of being a runtime for LXC, Docker is the Registry client. It supports:
66
+- Push / Pull on the registry
67
+- Client authentication on the Index
68
+
69
+2. Workflow
70
+===========
71
+
72
+2.1 Pull
73
+--------
74
+
75
+.. image:: /static_files/docker_pull_chart.png
76
+
77
+1. Contact the Index to know where I should download “samalba/busybox”
78
+2. Index replies:
79
+   a. “samalba/busybox” is on Registry A
80
+   b. here are the checksums for “samalba/busybox” (for all layers)
81
+   c. token
82
+3. Contact Registry A to receive the layers for “samalba/busybox” (all of them to the base image). Registry A is authoritative for “samalba/busybox” but keeps a copy of all inherited layers and serve them all from the same location.
83
+4. registry contacts index to verify if token/user is allowed to download images
84
+5. Index returns true/false lettings registry know if it should proceed or error out
85
+6. Get the payload for all layers
86
+
87
+It’s possible to run docker pull https://<registry>/repositories/samalba/busybox. In this case, docker bypasses the Index. However the security is not guaranteed (in case Registry A is corrupted) because there won’t be any checksum checks.
88
+
89
+Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
90
+
91
+Token is only returned when the 'X-Docker-Token' header is sent with request.
92
+
93
+Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
94
+
95
+API (pulling repository foo/bar):
96
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
+
98
+1. (Docker -> Index) GET /v1/repositories/foo/bar/images
99
+    **Headers**:
100
+        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
101
+        X-Docker-Token: true
102
+    **Action**:
103
+        (looking up the foo/bar in db and gets images and checksums for that repo (all if no tag is specified, if tag, only checksums for those tags) see part 4.4.1)
104
+
105
+2. (Index -> Docker) HTTP 200 OK
106
+
107
+    **Headers**:
108
+        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
109
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
110
+    **Body**:
111
+        Jsonified checksums (see part 4.4.1)
112
+
113
+3. (Docker -> Registry) GET /v1/repositories/foo/bar/tags/latest
114
+    **Headers**:
115
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
116
+
117
+4. (Registry -> Index) GET /v1/repositories/foo/bar/images
118
+
119
+    **Headers**:
120
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
121
+
122
+    **Body**:
123
+        <ids and checksums in payload>
124
+
125
+    **Action**:
126
+        ( Lookup token see if they have access to pull.)
127
+
128
+        If good:
129
+            HTTP 200 OK
130
+            Index will invalidate the token
131
+        If bad:
132
+            HTTP 401 Unauthorized
133
+
134
+5. (Docker -> Registry) GET /v1/images/928374982374/ancestry
135
+    **Action**:
136
+        (for each image id returned in the registry, fetch /json + /layer)
137
+
138
+.. note::
139
+
140
+    If someone makes a second request, then we will always give a new token, never reuse tokens.
141
+
142
+2.2 Push
143
+--------
144
+
145
+.. image:: /static_files/docker_push_chart.png
146
+
147
+1. Contact the index to allocate the repository name “samalba/busybox” (authentication required with user credentials)
148
+2. If authentication works and namespace available, “samalba/busybox” is allocated and a temporary token is returned (namespace is marked as initialized in index)
149
+3. Push the image on the registry (along with the token)
150
+4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
151
+5. Index validates the token. Registry A starts reading the stream pushed by docker and store the repository (with its images)
152
+6. docker contacts the index to give checksums for upload images
153
+
154
+.. note::
155
+
156
+    **It’s possible not to use the Index at all!** In this case, a deployed version of the Registry is deployed to store and serve images. Those images are not authentified and the security is not guaranteed.
157
+
158
+.. note::
159
+
160
+    **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
161
+
162
+Docker computes the checksums and submit them to the Index at the end of the push. When a repository name does not have checksums on the Index, it means that the push is in progress (since checksums are submitted at the end).
163
+
164
+API (pushing repos foo/bar):
165
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
166
+
167
+1. (Docker -> Index) PUT /v1/repositories/foo/bar/
168
+    **Headers**:
169
+        Authorization: Basic sdkjfskdjfhsdkjfh==
170
+        X-Docker-Token: true
171
+
172
+    **Action**::
173
+        - in index, we allocated a new repository, and set to initialized
174
+
175
+    **Body**::
176
+        (The body contains the list of images that are going to be pushed, with empty checksums. The checksums will be set at the end of the push)::
177
+
178
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
179
+
180
+2. (Index -> Docker) 200 Created
181
+    **Headers**:
182
+        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
183
+        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
184
+
185
+3. (Docker -> Registry) PUT /v1/images/98765432_parent/json
186
+    **Headers**:
187
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
188
+
189
+4. (Registry->Index) GET /v1/repositories/foo/bar/images
190
+    **Headers**:
191
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
192
+    **Action**::
193
+        - Index:
194
+            will invalidate the token.
195
+        - Registry:
196
+            grants a session (if token is approved) and fetches the images id
197
+
198
+5. (Docker -> Registry) PUT /v1/images/98765432_parent/json
199
+    **Headers**::
200
+        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
201
+        - Cookie: (Cookie provided by the Registry)
202
+
203
+6. (Docker -> Registry) PUT /v1/images/98765432/json
204
+    **Headers**:
205
+        Cookie: (Cookie provided by the Registry)
206
+
207
+7. (Docker -> Registry) PUT /v1/images/98765432_parent/layer
208
+    **Headers**:
209
+        Cookie: (Cookie provided by the Registry)
210
+
211
+8. (Docker -> Registry) PUT /v1/images/98765432/layer
212
+    **Headers**:
213
+        X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
214
+
215
+9. (Docker -> Registry) PUT /v1/repositories/foo/bar/tags/latest
216
+    **Headers**:
217
+        Cookie: (Cookie provided by the Registry)
218
+    **Body**:
219
+        “98765432”
220
+
221
+10. (Docker -> Index) PUT /v1/repositories/foo/bar/images
222
+
223
+    **Headers**:
224
+        Authorization: Basic 123oislifjsldfj==
225
+        X-Docker-Endpoints: registry1.docker.io (no validation on this right now)
226
+
227
+    **Body**:
228
+        (The image, id’s, tags and checksums)
229
+
230
+        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
231
+        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
232
+
233
+    **Return** HTTP 204
234
+
235
+.. note::
236
+
237
+     If push fails and they need to start again, what happens in the index, there will already be a record for the namespace/name, but it will be initialized. Should we allow it, or mark as name already used? One edge case could be if someone pushes the same thing at the same time with two different shells.
238
+
239
+     If it's a retry on the Registry, Docker has a cookie (provided by the registry after token validation). So the Index won’t have to provide a new token.
240
+
241
+3. How to use the Registry in standalone mode
242
+=============================================
243
+
244
+The Index has two main purposes (along with its fancy social features):
245
+
246
+- Resolve short names (to avoid passing absolute URLs all the time)
247
+   - username/projectname -> https://registry.docker.io/users/<username>/repositories/<projectname>/
248
+   - team/projectname -> https://registry.docker.io/team/<team>/repositories/<projectname>/
249
+- Authenticate a user as a repos owner (for a central referenced repository)
250
+
251
+3.1 Without an Index
252
+--------------------
253
+Using the Registry without the Index can be useful to store the images on a private network without having to rely on an external entity controlled by dotCloud.
254
+
255
+In this case, the registry will be launched in a special mode (--standalone? --no-index?). In this mode, the only thing which changes is that Registry will never contact the Index to verify a token. It will be the Registry owner responsibility to authenticate the user who pushes (or even pulls) an image using any mechanism (HTTP auth, IP based, etc...).
256
+
257
+In this scenario, the Registry is responsible for the security in case of data corruption since the checksums are not delivered by a trusted entity.
258
+
259
+As hinted previously, a standalone registry can also be implemented by any HTTP server handling GET/PUT requests (or even only GET requests if no write access is necessary).
260
+
261
+3.2 With an Index
262
+-----------------
263
+
264
+The Index data needed by the Registry are simple:
265
+- Serve the checksums
266
+- Provide and authorize a Token
267
+
268
+In the scenario of a Registry running on a private network with the need of centralizing and authorizing, it’s easy to use a custom Index.
269
+
270
+The only challenge will be to tell Docker to contact (and trust) this custom Index. Docker will be configurable at some point to use a specific Index, it’ll be the private entity responsibility (basically the organization who uses Docker in a private environment) to maintain the Index and the Docker’s configuration among its consumers.
271
+
272
+4. The API
273
+==========
274
+
275
+The first version of the api is available here: https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md
276
+
277
+4.1 Images
278
+----------
279
+
280
+The format returned in the images is not defined here (for layer and json), basically because Registry stores exactly the same kind of information as Docker uses to manage them.
281
+
282
+The format of ancestry is a line-separated list of image ids, in age order. I.e. the image’s parent is on the last line, the parent of the parent on the next-to-last line, etc.; if the image has no parent, the file is empty.
283
+
284
+GET /v1/images/<image_id>/layer
285
+PUT /v1/images/<image_id>/layer
286
+GET /v1/images/<image_id>/json
287
+PUT /v1/images/<image_id>/json
288
+GET /v1/images/<image_id>/ancestry
289
+PUT /v1/images/<image_id>/ancestry
290
+
291
+4.2 Users
292
+---------
293
+
294
+4.2.1 Create a user (Index)
295
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
296
+
297
+POST /v1/users
298
+
299
+**Body**:
300
+    {"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
301
+
302
+**Validation**:
303
+    - **username** : min 4 character, max 30 characters, all lowercase no special characters.
304
+    - **password**: min 5 characters
305
+
306
+**Valid**: return HTTP 200
307
+
308
+Errors: HTTP 400 (we should create error codes for possible errors)
309
+- invalid json
310
+- missing field
311
+- wrong format (username, password, email, etc)
312
+- forbidden name
313
+- name already exists
314
+
315
+.. note::
316
+
317
+    A user account will be valid only if the email has been validated (a validation link is sent to the email address).
318
+
319
+4.2.2 Update a user (Index)
320
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
321
+
322
+PUT /v1/users/<username>
323
+
324
+**Body**:
325
+    {"password": "toto"}
326
+
327
+.. note::
328
+
329
+    We can also update email address, if they do, they will need to reverify their new email address.
330
+
331
+4.2.3 Login (Index)
332
+^^^^^^^^^^^^^^^^^^^
333
+Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
334
+
335
+GET /v1/users
336
+
337
+**Return**:
338
+    - Valid: HTTP 200
339
+    - Invalid login: HTTP 401
340
+    - Account inactive: HTTP 403 Account is not Active
341
+
342
+4.3 Tags (Registry)
343
+-------------------
344
+
345
+The Registry does not know anything about users. Even though repositories are under usernames, it’s just a namespace for the registry. Allowing us to implement organizations or different namespaces per user later, without modifying the Registry’s API.
346
+
347
+4.3.1 Get all tags
348
+^^^^^^^^^^^^^^^^^^
349
+
350
+GET /v1/repositories/<namespace>/<repository_name>/tags
351
+
352
+**Return**: HTTP 200
353
+    {
354
+    "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
355
+    “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
356
+    }
357
+
358
+4.3.2 Read the content of a tag (resolve the image id)
359
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
360
+
361
+GET /v1/repositories/<namespace>/<repo_name>/tags/<tag>
362
+
363
+**Return**:
364
+    "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
365
+
366
+4.3.3 Delete a tag (registry)
367
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
368
+
369
+DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
370
+
371
+4.4 Images (Index)
372
+------------------
373
+
374
+For the Index to “resolve” the repository name to a Registry location, it uses the X-Docker-Endpoints header. In other terms, this requests always add a “X-Docker-Endpoints” to indicate the location of the registry which hosts this repository.
375
+
376
+4.4.1 Get the images
377
+^^^^^^^^^^^^^^^^^^^^^
378
+
379
+GET /v1/repositories/<namespace>/<repo_name>/images
380
+
381
+**Return**: HTTP 200
382
+    [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
383
+
384
+
385
+4.4.2 Add/update the images
386
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
387
+
388
+You always add images, you never remove them.
389
+
390
+PUT /v1/repositories/<namespace>/<repo_name>/images
391
+
392
+**Body**:
393
+    [ {“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”} ]
394
+
395
+**Return** 204
396
+
397
+5. Chaining Registries
398
+======================
399
+
400
+It’s possible to chain Registries server for several reasons:
401
+- Load balancing
402
+- Delegate the next request to another server
403
+
404
+When a Registry is a reference for a repository, it should host the entire images chain in order to avoid breaking the chain during the download.
405
+
406
+The Index and Registry use this mechanism to redirect on one or the other.
407
+
408
+Example with an image download:
409
+On every request, a special header can be returned:
410
+
411
+X-Docker-Endpoints: server1,server2
412
+
413
+On the next request, the client will always pick a server from this list.
414
+
415
+6. Authentication & Authorization
416
+=================================
417
+
418
+6.1 On the Index
419
+-----------------
420
+
421
+The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
422
+
423
+    401 Unauthorized
424
+    WWW-Authenticate: Basic realm="auth required",Token
425
+
426
+You have 3 options:
427
+
428
+1. Provide user credentials and ask for a token
429
+
430
+    **Header**:
431
+        - Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
432
+        - X-Docker-Token: true
433
+
434
+    In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
435
+    If authorization isn't correct you get a 401 response.
436
+    If account isn't active you will get a 403 response.
437
+
438
+    **Response**:
439
+        - 200 OK
440
+        - X-Docker-Token: Token signature=123abc,repository=”foo/bar”,access=read
441
+
442
+2. Provide user credentials only
443
+
444
+    **Header**:
445
+        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
446
+
447
+3. Provide Token
448
+
449
+    **Header**:
450
+        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
451
+
452
+6.2 On the Registry
453
+-------------------
454
+
455
+The Registry only supports the Token challenge::
456
+
457
+    401 Unauthorized
458
+    WWW-Authenticate: Token
459
+
460
+The only way is to provide a token on “401 Unauthorized” responses::
461
+
462
+    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
463
+
464
+Usually, the Registry provides a Cookie when a Token verification succeeded. Every time the Registry passes a Cookie, you have to pass it back the same cookie.::
465
+
466
+    200 OK
467
+    Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly
468
+
469
+Next request::
470
+
471
+    GET /(...)
472
+    Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="
0 473
deleted file mode 100644
... ...
@@ -1,130 +0,0 @@
1
-==============
2
-Docker Builder
3
-==============
4
-
5
-.. contents:: Table of Contents
6
-
7
-1. Format
8
-=========
9
-
10
-The Docker builder format is quite simple:
11
-
12
-    ``instruction arguments``
13
-
14
-The first instruction must be `FROM`
15
-
16
-All instruction are to be placed in a file named `Dockerfile`
17
-
18
-In order to place comments within a Dockerfile, simply prefix the line with "`#`"
19
-
20
-2. Instructions
21
-===============
22
-
23
-Docker builder comes with a set of instructions:
24
-
25
-1. FROM: Set from what image to build
26
-2. RUN: Execute a command
27
-3. INSERT: Insert a remote file (http) into the image
28
-
29
-2.1 FROM
30
-    ``FROM <image>``
31
-
32
-The `FROM` instruction must be the first one in order for Builder to know from where to run commands.
33
-
34
-`FROM` can also be used in order to build multiple images within a single Dockerfile
35
-
36
-2.2 MAINTAINER
37
-    ``MAINTAINER <name>``
38
-
39
-The `MAINTAINER` instruction allow you to set the Author field of the generated images.
40
-This instruction is never automatically reset.
41
-
42
-2.3 RUN
43
-    ``RUN <command>``
44
-
45
-The `RUN` instruction is the main one, it allows you to execute any commands on the `FROM` image and to save the results.
46
-You can use as many `RUN` as you want within a Dockerfile, the commands will be executed on the result of the previous command.
47
-
48
-
49
-2.4 CMD
50
-    ``CMD <command>``
51
-
52
-The `CMD` instruction sets the command to be executed when running the image.
53
-It is equivalent to do `docker commit -run '{"Cmd": <command>}'` outside the builder.
54
-
55
-.. note::
56
-    Do not confuse `RUN` with `CMD`. `RUN` actually run a command and save the result, `CMD` does not execute anything.
57
-
58
-2.5 EXPOSE
59
-    ``EXPOSE <port> [<port>...]``
60
-
61
-The `EXPOSE` instruction sets ports to be publicly exposed when running the image.
62
-This is equivalent to do `docker commit -run '{"PortSpecs": ["<port>", "<port2>"]}'` outside the builder.
63
-
64
-2.6 ENV
65
-    ``ENV <key> <value>``
66
-
67
-The `ENV` instruction set as environment variable `<key>` with the value `<value>`. This value will be passed to all future ``RUN`` instructions.
68
-
69
-.. note::
70
-    The environment variables are local to the Dockerfile, they will not be set as autorun.
71
-
72
-2.7 INSERT
73
-
74
-    ``INSERT <file url> <path>``
75
-
76
-The `INSERT` instruction will download the file at the given url and place it within the image at the given path.
77
-
78
-.. note::
79
-    The path must include the file name.
80
-
81
-
82
-3. Dockerfile Examples
83
-======================
84
-
85
-::
86
-
87
-    # Nginx
88
-    #
89
-    # VERSION               0.0.1
90
-    # DOCKER-VERSION        0.2
91
-    
92
-    from      ubuntu
93
-    maintainer Guillaume J. Charmes "guillaume@dotcloud.com"
94
-    
95
-    # make sure the package repository is up to date
96
-    run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
97
-    run apt-get update
98
-    
99
-    run apt-get install -y inotify-tools nginx apache2 openssh-server
100
-    insert https://raw.github.com/creack/docker-vps/master/nginx-wrapper.sh /usr/sbin/nginx-wrapper
101
-
102
-::
103
-
104
-    # Firefox over VNC
105
-    #
106
-    # VERSION               0.3
107
-    # DOCKER-VERSION        0.2
108
-    
109
-    from ubuntu
110
-    # make sure the package repository is up to date
111
-    run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
112
-    run apt-get update
113
-    
114
-    # Install vnc, xvfb in order to create a 'fake' display and firefox
115
-    run apt-get install -y x11vnc xvfb firefox
116
-    run mkdir /.vnc
117
-    # Setup a password
118
-    run x11vnc -storepasswd 1234 ~/.vnc/passwd
119
-    # Autostart firefox (might not be the best way to do it, but it does the trick)
120
-    run bash -c 'echo "firefox" >> /.bashrc'
121
-    
122
-    expose 5900
123
-    cmd    ["x11vnc", "-forever", "-usepw", "-create"]
124 1
deleted file mode 100644
... ...
@@ -1,14 +0,0 @@
1
-:title: docker documentation
2
-:description: Documentation for docker builder
3
-:keywords: docker, builder, dockerfile
4
-
5
-
6
-Builder
7
-=======
8
-
9
-Contents:
10
-
11
-.. toctree::
12
-  :maxdepth: 2
13
-
14
-  basics
15 1
deleted file mode 100644
... ...
@@ -1,101 +0,0 @@
1
-:title: Base commands
2
-:description: Common usage and commands
3
-:keywords: Examples, Usage
4
-
5
-
6
-The basics
7
-=============
8
-
9
-Starting Docker
10
-
11
-If you have used one of the quick install paths', Docker may have been installed with upstart, Ubuntu's
12
-system for starting processes at boot time. You should be able to run ``docker help`` and get output.
13
-
14
-If you get ``docker: command not found`` or something like ``/var/lib/docker/repositories: permission denied``
15
-you will need to specify the path to it and manually start it.
16
-
17
-.. code-block:: bash
18
-
19
-    # Run docker in daemon mode
20
-    sudo <path to>/docker -d &
21
-
22
-
23
-Running an interactive shell
24
-
25
-.. code-block:: bash
26
-
27
-  # Download a base image
28
-  docker pull base
29
-
30
-  # Run an interactive shell in the base image,
31
-  # allocate a tty, attach stdin and stdout
32
-  docker run -i -t base /bin/bash
33
-
34
-
35
-Starting a long-running worker process
36
-
37
-.. code-block:: bash
38
-
39
-  # Start a very useful long-running process
40
-  JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done")
41
-
42
-  # Collect the output of the job so far
43
-  docker logs $JOB
44
-
45
-  # Kill the job
46
-  docker kill $JOB
47
-
48
-
49
-Listing all running containers
50
-
51
-.. code-block:: bash
52
-
53
-  docker ps
54
-
55
-Expose a service on a TCP port
56
-
57
-.. code-block:: bash
58
-
59
-  # Expose port 4444 of this container, and tell netcat to listen on it
60
-  JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
61
-
62
-  # Which public port is NATed to my container?
63
-  PORT=$(docker port $JOB 4444)
64
-
65
-  # Connect to the public port via the host's public address
66
-  # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
67
-  IP=$(ifconfig eth0 | perl -n -e 'if (m/inet addr:([\d\.]+)/g) { print $1 }')
68
-  echo hello world | nc $IP $PORT
69
-
70
-  # Verify that the network connection worked
71
-  echo "Daemon received: $(docker logs $JOB)"
72
-
73
-
74
-Committing (saving) an image
75
-
76
-Save your containers state to a container image, so the state can be re-used.
77
-
78
-When you commit your container only the differences between the image the container was created from
79
-and the current state of the container will be stored (as a diff). See which images you already have
80
-using ``docker images``
81
-
82
-.. code-block:: bash
83
-
84
-    # Commit your container to a new named image
85
-    docker commit <container_id> <some_name>
86
-
87
-    # List your containers
88
-    docker images
89
-
90
-You now have a image state from which you can create new instances.
91
-
92
-
93
-
94
-Read more about :ref:`working_with_the_repository` or continue to the complete :ref:`cli`
95
-
... ...
@@ -4,7 +4,7 @@
4 4
 
5 5
 .. _cli:
6 6
 
7
-Command Line Interface
7
+Overview
8 8
 ======================
9 9
 
10 10
 Docker Usage
... ...
@@ -24,7 +24,7 @@ Available Commands
24 24
 ~~~~~~~~~~~~~~~~~~
25 25
 
26 26
 .. toctree::
27
-   :maxdepth: 1
27
+   :maxdepth: 2
28 28
 
29 29
    command/attach
30 30
    command/build
... ...
@@ -11,6 +11,31 @@ Contents:
11 11
 .. toctree::
12 12
   :maxdepth: 3
13 13
 
14
-  basics
15
-  workingwithrepository
16 14
   cli
15
+  command/attach
16
+  command/build
17
+  command/commit
18
+  command/diff
19
+  command/export
20
+  command/history
21
+  command/images
22
+  command/import
23
+  command/info
24
+  command/inspect
25
+  command/kill
26
+  command/login
27
+  command/logs
28
+  command/port
29
+  command/ps
30
+  command/pull
31
+  command/push
32
+  command/restart
33
+  command/rm
34
+  command/rmi
35
+  command/run
36
+  command/search
37
+  command/start
38
+  command/stop
39
+  command/tag
40
+  command/version
41
+  command/wait
17 42
\ No newline at end of file
18 43
deleted file mode 100644
... ...
@@ -1,42 +0,0 @@
1
-.. _working_with_the_repository:
2
-
3
-Working with the repository
4
-============================
5
-
6
-Connecting to the repository
7
-
8
-You create a user on the central docker repository by running
9
-
10
-.. code-block:: bash
11
-
12
-    docker login
13
-
14
-
15
-If your username does not exist it will prompt you to also enter a password and your e-mail address. It will then
16
-automatically log you in.
17
-
18
-
19
-Committing a container to a named image
20
-
21
-In order to commit to the repository it is required to have committed your container to an image with your namespace.
22
-
23
-.. code-block:: bash
24
-
25
-    # for example docker commit $CONTAINER_ID dhrp/kickassapp
26
-    docker commit <container_id> <your username>/<some_name>
27
-
28
-
29
-Pushing a container to the repository
30
-
31
-In order to push an image to the repository you need to have committed your container to a named image (see above)
32
-
33
-Now you can commit this image to the repository
34
-
35
-.. code-block:: bash
36
-
37
-    # for example docker push dhrp/kickassapp
38
-    docker push <image-name>
39
-
40 1
new file mode 100644
41 2
Binary files /dev/null and b/docs/sources/concepts/images/lego_docker.jpg differ
... ...
@@ -20,7 +20,7 @@ Docker is a great building block for automating distributed systems: large-scale
20 20
 - **Isolation** docker isolates processes from each other and from the underlying host, using lightweight containers.
21 21
 - **Repeatability** Because containers are isolated in their own filesystem, they behave the same regardless of where, when, and alongside what they run.
22 22
 
23
-.. image:: http://www.docker.io/_static/lego_docker.jpg
23
+.. image:: images/lego_docker.jpg
24 24
 
25 25
 
26 26
 What is a Standard Container?
... ...
@@ -12,14 +12,11 @@ This documentation has the following resources:
12 12
 
13 13
    concepts/index
14 14
    installation/index
15
+   use/index
15 16
    examples/index
16
-   contributing/index
17 17
    commandline/index
18
-   registry/index
19
-   index/index
20
-   builder/index
21
-   remote-api/index
18
+   contributing/index
19
+   api/index
22 20
    faq
23 21
 
24
-
25
-.. image:: http://www.docker.io/_static/lego_docker.jpg
22
+.. image:: concepts/images/lego_docker.jpg
26 23
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-:title: Docker Index documentation
2
-:description: Documentation for docker Index
3
-:keywords: docker, index, api
4
-
5
-
6
-
7
-Index
8
-=====
9
-
10
-Contents:
11
-
12
-.. toctree::
13
-   :maxdepth: 2
14
-
15
-   search
16 1
deleted file mode 100644
... ...
@@ -1,38 +0,0 @@
1
-=======================
2
-Docker Index Search API
3
-=======================
4
-
5
-Search
6
-
7
-.. http:get:: /v1/search
8
-
9
-   Search the Index given a search term. It accepts :http:method:`get` only.
10
-
11
-   **Example request**:
12
-
13
-   .. sourcecode:: http
14
-
15
-      GET /v1/search?q=search_term HTTP/1.1
16
-      Host: example.com
17
-      Accept: application/json
18
-
19
-   **Example response**:
20
-
21
-   .. sourcecode:: http
22
-
23
-      HTTP/1.1 200 OK
24
-      Vary: Accept
25
-      Content-Type: application/json
26
-
27
-      {"query":"search_term",
28
-        "num_results": 2,
29
-        "results" : [
30
-           {"name": "dotcloud/base", "description": "A base ubuntu64  image..."},
31
-           {"name": "base2", "description": "A base ubuntu64  image..."},
32
-         ]
33
-       }
34
-   
35
-   :query q: what you want to search for
36
-   :statuscode 200: no error
37
-   :statuscode 500: server error
38 1
\ No newline at end of file
39 2
deleted file mode 100644
... ...
@@ -1,468 +0,0 @@
1
-===================
2
-Docker Registry API
3
-===================
4
-
5
-.. contents:: Table of Contents
6
-
7
-1. The 3 roles
8
-===============
9
-
10
-1.1 Index
11
-
12
-The Index is responsible for centralizing information about:
13
-- User accounts
14
-- Checksums of the images
15
-- Public namespaces
16
-
17
-The Index has different components:
18
-- Web UI
19
-- Meta-data store (comments, stars, list public repositories)
20
-- Authentication service
21
-- Tokenization
22
-
23
-The index is authoritative for those information.
24
-
25
-We expect that there will be only one instance of the index, run and managed by dotCloud.
26
-
27
-1.2 Registry
28
-- It stores the images and the graph for a set of repositories
29
-- It does not have user accounts data
30
-- It has no notion of user accounts or authorization
31
-- It delegates authentication and authorization to the Index Auth service using tokens
32
-- It supports different storage backends (S3, cloud files, local FS)
33
-- It doesn’t have a local database
34
-- It will be open-sourced at some point
35
-
36
-We expect that there will be multiple registries out there. To help to grasp the context, here are some examples of registries:
37
-
38
-- **sponsor registry**: such a registry is provided by a third-party hosting infrastructure as a convenience for their customers and the docker community as a whole. Its costs are supported by the third party, but the management and operation of the registry are supported by dotCloud. It features read/write access, and delegates authentication and authorization to the Index.
39
-- **mirror registry**: such a registry is provided by a third-party hosting infrastructure but is targeted at their customers only. Some mechanism (unspecified to date) ensures that public images are pulled from a sponsor registry to the mirror registry, to make sure that the customers of the third-party provider can “docker pull” those images locally.
40
-- **vendor registry**: such a registry is provided by a software vendor, who wants to distribute docker images. It would be operated and managed by the vendor. Only users authorized by the vendor would be able to get write access. Some images would be public (accessible for anyone), others private (accessible only for authorized users). Authentication and authorization would be delegated to the Index. The goal of vendor registries is to let someone do “docker pull basho/riak1.3” and automatically push from the vendor registry (instead of a sponsor registry); i.e. get all the convenience of a sponsor registry, while retaining control on the asset distribution.
41
-- **private registry**: such a registry is located behind a firewall, or protected by an additional security layer (HTTP authorization, SSL client-side certificates, IP address authorization...). The registry is operated by a private entity, outside of dotCloud’s control. It can optionally delegate additional authorization to the Index, but it is not mandatory.
42
-
43
-.. note::
44
-
45
-    Mirror registries and private registries which do not use the Index don’t even need to run the registry code. They can be implemented by any kind of transport implementing HTTP GET and PUT. Read-only registries can be powered by a simple static HTTP server. 
46
-
47
-.. note::
48
-
49
-    The latter implies that while HTTP is the protocol of choice for a registry, multiple schemes are possible (and in some cases, trivial):
50
-        - HTTP with GET (and PUT for read-write registries);
51
-        - local mount point;
52
-        - remote docker addressed through SSH.
53
-
54
-The latter would only require two new commands in docker, e.g. “registryget” and “registryput”, wrapping access to the local filesystem (and optionally doing consistency checks). Authentication and authorization are then delegated to SSH (e.g. with public keys).
55
-
56
-1.3 Docker
57
-
58
-On top of being a runtime for LXC, Docker is the Registry client. It supports:
59
-- Push / Pull on the registry
60
-- Client authentication on the Index
61
-
62
-2. Workflow
63
-===========
64
-
65
-2.1 Pull
66
-
67
-.. image:: /static_files/docker_pull_chart.png
68
-
69
-1. Contact the Index to know where I should download “samalba/busybox”
70
-2. Index replies:
71
-   a. “samalba/busybox” is on Registry A
72
-   b. here are the checksums for “samalba/busybox” (for all layers)
73
-   c. token
74
-3. Contact Registry A to receive the layers for “samalba/busybox” (all of them to the base image). Registry A is authoritative for “samalba/busybox” but keeps a copy of all inherited layers and serve them all from the same location.
75
-4. registry contacts index to verify if token/user is allowed to download images
76
-5. Index returns true/false lettings registry know if it should proceed or error out
77
-6. Get the payload for all layers
78
-
79
-It’s possible to run docker pull https://<registry>/repositories/samalba/busybox. In this case, docker bypasses the Index. However the security is not guaranteed (in case Registry A is corrupted) because there won’t be any checksum checks.
80
-
81
-Currently registry redirects to s3 urls for downloads, going forward all downloads need to be streamed through the registry. The Registry will then abstract the calls to S3 by a top-level class which implements sub-classes for S3 and local storage.
82
-
83
-Token is only returned when the 'X-Docker-Token' header is sent with request.
84
-
85
-Basic Auth is required to pull private repos. Basic auth isn't required for pulling public repos, but if one is provided, it needs to be valid and for an active account.
86
-
87
-API (pulling repository foo/bar):
88
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89
-
90
-1. (Docker -> Index) GET /v1/repositories/foo/bar/images
91
-    **Headers**:
92
-        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
93
-        X-Docker-Token: true
94
-    **Action**:
95
-        (looking up the foo/bar in db and gets images and checksums for that repo (all if no tag is specified, if tag, only checksums for those tags) see part 4.4.1)
96
-
97
-2. (Index -> Docker) HTTP 200 OK
98
-
99
-    **Headers**:
100
-        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
101
-        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
102
-    **Body**:
103
-        Jsonified checksums (see part 4.4.1)
104
-
105
-3. (Docker -> Registry) GET /v1/repositories/foo/bar/tags/latest
106
-    **Headers**: 
107
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
108
-
109
-4. (Registry -> Index) GET /v1/repositories/foo/bar/images
110
-
111
-    **Headers**:
112
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
113
-
114
-    **Body**:
115
-        <ids and checksums in payload>
116
-
117
-    **Action**:
118
-        ( Lookup token see if they have access to pull.)
119
-
120
-        If good: 
121
-            HTTP 200 OK
122
-            Index will invalidate the token
123
-        If bad: 
124
-            HTTP 401 Unauthorized
125
-
126
-5. (Docker -> Registry) GET /v1/images/928374982374/ancestry
127
-    **Action**:
128
-        (for each image id returned in the registry, fetch /json + /layer)
129
-
130
-.. note::
131
-
132
-    If someone makes a second request, then we will always give a new token, never reuse tokens.
133
-
134
-2.2 Push
135
-
136
-.. image:: /static_files/docker_push_chart.png
137
-
138
-1. Contact the index to allocate the repository name “samalba/busybox” (authentication required with user credentials)
139
-2. If authentication works and namespace available, “samalba/busybox” is allocated and a temporary token is returned (namespace is marked as initialized in index)
140
-3. Push the image on the registry (along with the token)
141
-4. Registry A contacts the Index to verify the token (token must corresponds to the repository name)
142
-5. Index validates the token. Registry A starts reading the stream pushed by docker and store the repository (with its images)
143
-6. docker contacts the index to give checksums for upload images
144
-
145
-.. note::
146
-
147
-    **It’s possible not to use the Index at all!** In this case, a deployed version of the Registry is deployed to store and serve images. Those images are not authentified and the security is not guaranteed.
148
-
149
-.. note::
150
-
151
-    **Index can be replaced!** For a private Registry deployed, a custom Index can be used to serve and validate token according to different policies.
152
-
153
-Docker computes the checksums and submit them to the Index at the end of the push. When a repository name does not have checksums on the Index, it means that the push is in progress (since checksums are submitted at the end).
154
-
155
-API (pushing repos foo/bar):
156
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157
-
158
-1. (Docker -> Index) PUT /v1/repositories/foo/bar/
159
-    **Headers**:
160
-        Authorization: Basic sdkjfskdjfhsdkjfh==
161
-        X-Docker-Token: true
162
-
163
-    **Action**::
164
-        - in index, we allocated a new repository, and set to initialized
165
-
166
-    **Body**::
167
-        (The body contains the list of images that are going to be pushed, with empty checksums. The checksums will be set at the end of the push)::
168
-
169
-        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
170
-
171
-2. (Index -> Docker) 200 Created
172
-    **Headers**:
173
-        - WWW-Authenticate: Token signature=123abc,repository=”foo/bar”,access=write
174
-        - X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
175
-
176
-3. (Docker -> Registry) PUT /v1/images/98765432_parent/json
177
-    **Headers**:
178
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
179
-
180
-4. (Registry->Index) GET /v1/repositories/foo/bar/images
181
-    **Headers**:
182
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=write
183
-    **Action**::
184
-        - Index: 
185
-            will invalidate the token.
186
-        - Registry: 
187
-            grants a session (if token is approved) and fetches the images id
188
-
189
-5. (Docker -> Registry) PUT /v1/images/98765432_parent/json
190
-    **Headers**::
191
-        - Authorization: Token signature=123abc,repository=”foo/bar”,access=write
192
-        - Cookie: (Cookie provided by the Registry)
193
-
194
-6. (Docker -> Registry) PUT /v1/images/98765432/json
195
-    **Headers**:
196
-        Cookie: (Cookie provided by the Registry)
197
-
198
-7. (Docker -> Registry) PUT /v1/images/98765432_parent/layer
199
-    **Headers**:
200
-        Cookie: (Cookie provided by the Registry)
201
-
202
-8. (Docker -> Registry) PUT /v1/images/98765432/layer
203
-    **Headers**:
204
-        X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
205
-
206
-9. (Docker -> Registry) PUT /v1/repositories/foo/bar/tags/latest
207
-    **Headers**:
208
-        Cookie: (Cookie provided by the Registry)
209
-    **Body**:
210
-        “98765432”
211
-
212
-10. (Docker -> Index) PUT /v1/repositories/foo/bar/images
213
-
214
-    **Headers**:
215
-        Authorization: Basic 123oislifjsldfj==
216
-        X-Docker-Endpoints: registry1.docker.io (no validation on this right now)
217
-
218
-    **Body**:
219
-        (The image, id’s, tags and checksums)
220
-
221
-        [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, 
222
-        “checksum”: “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
223
-
224
-    **Return** HTTP 204
225
-
226
-.. note::
227
-
228
-     If push fails and they need to start again, what happens in the index, there will already be a record for the namespace/name, but it will be initialized. Should we allow it, or mark as name already used? One edge case could be if someone pushes the same thing at the same time with two different shells.
229
-
230
-     If it's a retry on the Registry, Docker has a cookie (provided by the registry after token validation). So the Index won’t have to provide a new token.
231
-
232
-3. How to use the Registry in standalone mode
233
-=============================================
234
-
235
-The Index has two main purposes (along with its fancy social features):
236
-
237
-- Resolve short names (to avoid passing absolute URLs all the time)
238
-   - username/projectname -> https://registry.docker.io/users/<username>/repositories/<projectname>/
239
-   - team/projectname -> https://registry.docker.io/team/<team>/repositories/<projectname>/
240
-- Authenticate a user as a repos owner (for a central referenced repository)
241
-
242
-3.1 Without an Index
243
-Using the Registry without the Index can be useful to store the images on a private network without having to rely on an external entity controlled by dotCloud.
244
-
245
-In this case, the registry will be launched in a special mode (--standalone? --no-index?). In this mode, the only thing which changes is that Registry will never contact the Index to verify a token. It will be the Registry owner responsibility to authenticate the user who pushes (or even pulls) an image using any mechanism (HTTP auth, IP based, etc...).
246
-
247
-In this scenario, the Registry is responsible for the security in case of data corruption since the checksums are not delivered by a trusted entity.
248
-
249
-As hinted previously, a standalone registry can also be implemented by any HTTP server handling GET/PUT requests (or even only GET requests if no write access is necessary).
250
-
251
-3.2 With an Index
252
-
253
-The Index data needed by the Registry are simple:
254
-- Serve the checksums
255
-- Provide and authorize a Token
256
-
257
-In the scenario of a Registry running on a private network with the need of centralizing and authorizing, it’s easy to use a custom Index.
258
-
259
-The only challenge will be to tell Docker to contact (and trust) this custom Index. Docker will be configurable at some point to use a specific Index, it’ll be the private entity responsibility (basically the organization who uses Docker in a private environment) to maintain the Index and the Docker’s configuration among its consumers.
260
-
261
-4. The API
262
-==========
263
-
264
-The first version of the api is available here: https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md
265
-
266
-4.1 Images
267
-
268
-The format returned in the images is not defined here (for layer and json), basically because Registry stores exactly the same kind of information as Docker uses to manage them.
269
-
270
-The format of ancestry is a line-separated list of image ids, in age order. I.e. the image’s parent is on the last line, the parent of the parent on the next-to-last line, etc.; if the image has no parent, the file is empty.
271
-
272
-GET /v1/images/<image_id>/layer
273
-PUT /v1/images/<image_id>/layer
274
-GET /v1/images/<image_id>/json
275
-PUT /v1/images/<image_id>/json
276
-GET /v1/images/<image_id>/ancestry
277
-PUT /v1/images/<image_id>/ancestry
278
-
279
-4.2 Users
280
-
281
-4.2.1 Create a user (Index)
282
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
283
-
284
-POST /v1/users
285
-
286
-**Body**:
287
-    {"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
288
-
289
-**Validation**:
290
-    - **username** : min 4 character, max 30 characters, all lowercase no special characters. 
291
-    - **password**: min 5 characters
292
-
293
-**Valid**: return HTTP 200
294
-
295
-Errors: HTTP 400 (we should create error codes for possible errors)
296
-- invalid json
297
-- missing field
298
-- wrong format (username, password, email, etc)
299
-- forbidden name
300
-- name already exists
301
-
302
-.. note::
303
-
304
-    A user account will be valid only if the email has been validated (a validation link is sent to the email address).
305
-
306
-4.2.2 Update a user (Index)
307
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
308
-
309
-PUT /v1/users/<username>
310
-
311
-**Body**:
312
-    {"password": "toto"}
313
-
314
-.. note::
315
-
316
-    We can also update email address, if they do, they will need to reverify their new email address.
317
-
318
-4.2.3 Login (Index)
319
-^^^^^^^^^^^^^^^^^^^
320
-Does nothing else but asking for a user authentication. Can be used to validate credentials. HTTP Basic Auth for now, maybe change in future.
321
-
322
-GET /v1/users
323
-
324
-**Return**:
325
-    - Valid: HTTP 200
326
-    - Invalid login: HTTP 401
327
-    - Account inactive: HTTP 403 Account is not Active
328
-
329
-4.3 Tags (Registry)
330
-
331
-The Registry does not know anything about users. Even though repositories are under usernames, it’s just a namespace for the registry. Allowing us to implement organizations or different namespaces per user later, without modifying the Registry’s API.
332
-
333
-4.3.1 Get all tags
334
-^^^^^^^^^^^^^^^^^^
335
-
336
-GET /v1/repositories/<namespace>/<repository_name>/tags
337
-
338
-**Return**: HTTP 200
339
-    {
340
-    "latest": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
341
-    “0.1.1”:  “b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”
342
-    }
343
-
344
-4.3.2 Read the content of a tag (resolve the image id)
345
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
346
-
347
-GET /v1/repositories/<namespace>/<repo_name>/tags/<tag>
348
-
349
-**Return**:
350
-    "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"
351
-
352
-4.3.3 Delete a tag (registry)
353
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
354
-
355
-DELETE /v1/repositories/<namespace>/<repo_name>/tags/<tag>
356
-
357
-4.4 Images (Index)
358
-
359
-For the Index to “resolve” the repository name to a Registry location, it uses the X-Docker-Endpoints header. In other terms, this requests always add a “X-Docker-Endpoints” to indicate the location of the registry which hosts this repository.
360
-
361
-4.4.1 Get the images
362
-^^^^^^^^^^^^^^^^^^^^^
363
-
364
-GET /v1/repositories/<namespace>/<repo_name>/images
365
-
366
-**Return**: HTTP 200
367
-    [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
368
-
369
-
370
-4.4.2 Add/update the images
371
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
372
-
373
-You always add images, you never remove them.
374
-
375
-PUT /v1/repositories/<namespace>/<repo_name>/images
376
-
377
-**Body**:
378
-    [ {“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”, “checksum”: “sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”} ]
379
-    
380
-**Return** 204
381
-
382
-5. Chaining Registries
383
-======================
384
-
385
-It’s possible to chain Registries server for several reasons:
386
-- Load balancing
387
-- Delegate the next request to another server
388
-
389
-When a Registry is a reference for a repository, it should host the entire images chain in order to avoid breaking the chain during the download.
390
-
391
-The Index and Registry use this mechanism to redirect on one or the other.
392
-
393
-Example with an image download:
394
-On every request, a special header can be returned:
395
-
396
-X-Docker-Endpoints: server1,server2
397
-
398
-On the next request, the client will always pick a server from this list.
399
-
400
-6. Authentication & Authorization
401
-=================================
402
-
403
-6.1 On the Index
404
-
405
-The Index supports both “Basic” and “Token” challenges. Usually when there is a “401 Unauthorized”, the Index replies this::
406
-
407
-    401 Unauthorized
408
-    WWW-Authenticate: Basic realm="auth required",Token
409
-
410
-You have 3 options:
411
-
412
-1. Provide user credentials and ask for a token
413
-
414
-    **Header**:
415
-        - Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
416
-        - X-Docker-Token: true
417
-
418
-    In this case, along with the 200 response, you’ll get a new token (if user auth is ok):
419
-    If authorization isn't correct you get a 401 response.
420
-    If account isn't active you will get a 403 response.
421
-
422
-    **Response**:
423
-        - 200 OK
424
-        - X-Docker-Token: Token signature=123abc,repository=”foo/bar”,access=read
425
-
426
-2. Provide user credentials only
427
-
428
-    **Header**:
429
-        Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
430
-
431
-3. Provide Token
432
-
433
-    **Header**:
434
-        Authorization: Token signature=123abc,repository=”foo/bar”,access=read
435
-
436
-6.2 On the Registry
437
-
438
-The Registry only supports the Token challenge::
439
-
440
-    401 Unauthorized
441
-    WWW-Authenticate: Token
442
-
443
-The only way is to provide a token on “401 Unauthorized” responses::
444
-
445
-    Authorization: Token signature=123abc,repository=”foo/bar”,access=read
446
-
447
-Usually, the Registry provides a Cookie when a Token verification succeeded. Every time the Registry passes a Cookie, you have to pass it back the same cookie.::
448
-
449
-    200 OK
450
-    Set-Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="; Path=/; HttpOnly
451
-
452
-Next request::
453
-
454
-    GET /(...)
455
-    Cookie: session="wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4="
456 1
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-:title: docker Registry documentation
2
-:description: Documentation for docker Registry and Registry API
3
-:keywords: docker, registry, api, index
4
-
5
-
6
-
7
-Registry
8
-========
9
-
10
-Contents:
11
-
12
-.. toctree::
13
-   :maxdepth: 2
14
-
15
-   api
16 1
deleted file mode 100644
17 2
Binary files a/docs/sources/static_files/lego_docker.jpg and /dev/null differ
18 3
new file mode 100644
... ...
@@ -0,0 +1,101 @@
0
+:title: Base commands
1
+:description: Common usage and commands
2
+:keywords: Examples, Usage
3
+
4
+
5
+The basics
6
+=============
7
+
8
+Starting Docker
9
+---------------
10
+
11
+If you have used one of the quick install paths', Docker may have been installed with upstart, Ubuntu's
12
+system for starting processes at boot time. You should be able to run ``docker help`` and get output.
13
+
14
+If you get ``docker: command not found`` or something like ``/var/lib/docker/repositories: permission denied``
15
+you will need to specify the path to it and manually start it.
16
+
17
+.. code-block:: bash
18
+
19
+    # Run docker in daemon mode
20
+    sudo <path to>/docker -d &
21
+
22
+
23
+Running an interactive shell
24
+----------------------------
25
+
26
+.. code-block:: bash
27
+
28
+  # Download a base image
29
+  docker pull base
30
+
31
+  # Run an interactive shell in the base image,
32
+  # allocate a tty, attach stdin and stdout
33
+  docker run -i -t base /bin/bash
34
+
35
+
36
+Starting a long-running worker process
37
+--------------------------------------
38
+
39
+.. code-block:: bash
40
+
41
+  # Start a very useful long-running process
42
+  JOB=$(docker run -d base /bin/sh -c "while true; do echo Hello world; sleep 1; done")
43
+
44
+  # Collect the output of the job so far
45
+  docker logs $JOB
46
+
47
+  # Kill the job
48
+  docker kill $JOB
49
+
50
+
51
+Listing all running containers
52
+------------------------------
53
+
54
+.. code-block:: bash
55
+
56
+  docker ps
57
+
58
+Expose a service on a TCP port
59
+------------------------------
60
+
61
+.. code-block:: bash
62
+
63
+  # Expose port 4444 of this container, and tell netcat to listen on it
64
+  JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
65
+
66
+  # Which public port is NATed to my container?
67
+  PORT=$(docker port $JOB 4444)
68
+
69
+  # Connect to the public port via the host's public address
70
+  # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
71
+  IP=$(ifconfig eth0 | perl -n -e 'if (m/inet addr:([\d\.]+)/g) { print $1 }')
72
+  echo hello world | nc $IP $PORT
73
+
74
+  # Verify that the network connection worked
75
+  echo "Daemon received: $(docker logs $JOB)"
76
+
77
+
78
+Committing (saving) a container state
79
+-------------------------------------
80
+
81
+Save your containers state to a container image, so the state can be re-used.
82
+
83
+When you commit your container only the differences between the image the container was created from
84
+and the current state of the container will be stored (as a diff). See which images you already have
85
+using ``docker images``
86
+
87
+.. code-block:: bash
88
+
89
+    # Commit your container to a new named image
90
+    docker commit <container_id> <some_name>
91
+
92
+    # List your containers
93
+    docker images
94
+
95
+You now have a image state from which you can create new instances.
96
+
97
+
98
+
99
+Read more about :ref:`working_with_the_repository` or continue to the complete :ref:`cli`
100
+
0 101
new file mode 100644
... ...
@@ -0,0 +1,130 @@
0
+==============
1
+Docker Builder
2
+==============
3
+
4
+.. contents:: Table of Contents
5
+
6
+1. Format
7
+=========
8
+
9
+The Docker builder format is quite simple:
10
+
11
+    ``instruction arguments``
12
+
13
+The first instruction must be `FROM`
14
+
15
+All instruction are to be placed in a file named `Dockerfile`
16
+
17
+In order to place comments within a Dockerfile, simply prefix the line with "`#`"
18
+
19
+2. Instructions
20
+===============
21
+
22
+Docker builder comes with a set of instructions:
23
+
24
+1. FROM: Set from what image to build
25
+2. RUN: Execute a command
26
+3. INSERT: Insert a remote file (http) into the image
27
+
28
+2.1 FROM
29
+--------
30
+    ``FROM <image>``
31
+
32
+The `FROM` instruction must be the first one in order for Builder to know from where to run commands.
33
+
34
+`FROM` can also be used in order to build multiple images within a single Dockerfile
35
+
36
+2.2 MAINTAINER
37
+--------------
38
+    ``MAINTAINER <name>``
39
+
40
+The `MAINTAINER` instruction allow you to set the Author field of the generated images.
41
+This instruction is never automatically reset.
42
+
43
+2.3 RUN
44
+-------
45
+    ``RUN <command>``
46
+
47
+The `RUN` instruction is the main one, it allows you to execute any commands on the `FROM` image and to save the results.
48
+You can use as many `RUN` as you want within a Dockerfile, the commands will be executed on the result of the previous command.
49
+
50
+
51
+2.4 CMD
52
+-------
53
+    ``CMD <command>``
54
+
55
+The `CMD` instruction sets the command to be executed when running the image.
56
+It is equivalent to do `docker commit -run '{"Cmd": <command>}'` outside the builder.
57
+
58
+.. note::
59
+    Do not confuse `RUN` with `CMD`. `RUN` actually run a command and save the result, `CMD` does not execute anything.
60
+
61
+2.5 EXPOSE
62
+----------
63
+    ``EXPOSE <port> [<port>...]``
64
+
65
+The `EXPOSE` instruction sets ports to be publicly exposed when running the image.
66
+This is equivalent to do `docker commit -run '{"PortSpecs": ["<port>", "<port2>"]}'` outside the builder.
67
+
68
+2.6 ENV
69
+-------
70
+    ``ENV <key> <value>``
71
+
72
+The `ENV` instruction set as environment variable `<key>` with the value `<value>`. This value will be passed to all future ``RUN`` instructions.
73
+
74
+.. note::
75
+    The environment variables are local to the Dockerfile, they will not be set as autorun.
76
+
77
+2.7 INSERT
78
+----------
79
+
80
+    ``INSERT <file url> <path>``
81
+
82
+The `INSERT` instruction will download the file at the given url and place it within the image at the given path.
83
+
84
+.. note::
85
+    The path must include the file name.
86
+
87
+
88
+3. Dockerfile Examples
89
+======================
90
+
91
+::
92
+
93
+    # Nginx
94
+    #
95
+    # VERSION               0.0.1
96
+    # DOCKER-VERSION        0.2
97
+    
98
+    from      ubuntu
99
+    maintainer Guillaume J. Charmes "guillaume@dotcloud.com"
100
+    
101
+    # make sure the package repository is up to date
102
+    run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
103
+    run apt-get update
104
+    
105
+    run apt-get install -y inotify-tools nginx apache2 openssh-server
106
+    insert https://raw.github.com/creack/docker-vps/master/nginx-wrapper.sh /usr/sbin/nginx-wrapper
107
+
108
+::
109
+
110
+    # Firefox over VNC
111
+    #
112
+    # VERSION               0.3
113
+    # DOCKER-VERSION        0.2
114
+    
115
+    from ubuntu
116
+    # make sure the package repository is up to date
117
+    run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
118
+    run apt-get update
119
+    
120
+    # Install vnc, xvfb in order to create a 'fake' display and firefox
121
+    run apt-get install -y x11vnc xvfb firefox
122
+    run mkdir /.vnc
123
+    # Setup a password
124
+    run x11vnc -storepasswd 1234 ~/.vnc/passwd
125
+    # Autostart firefox (might not be the best way to do it, but it does the trick)
126
+    run bash -c 'echo "firefox" >> /.bashrc'
127
+    
128
+    expose 5900
129
+    cmd    ["x11vnc", "-forever", "-usepw", "-create"]
0 130
new file mode 100644
... ...
@@ -0,0 +1,18 @@
0
+:title: docker documentation
1
+:description: -- todo: change me
2
+:keywords: todo: change me
3
+
4
+
5
+
6
+Use
7
+========
8
+
9
+Contents:
10
+
11
+.. toctree::
12
+   :maxdepth: 1
13
+
14
+   basics
15
+   workingwithrepository
16
+   builder
17
+
0 18
new file mode 100644
... ...
@@ -0,0 +1,75 @@
0
+.. _working_with_the_repository:
1
+
2
+Working with the repository
3
+============================
4
+
5
+
6
+Top-level repositories and user repositories
7
+--------------------------------------------
8
+
9
+Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind
10
+Docker, and user repositories.
11
+
12
+* Top-level repositories can easily be recognized by not having a / (slash) in their name. These repositories can
13
+  generally be trusted.
14
+* User repositories always come in the form of <username>/<repo_name>. This is what your published images will look like.
15
+* User images are not checked, it is therefore up to you whether or not you trust the creator of this image.
16
+
17
+
18
+Find public images available on the index
19
+-----------------------------------------
20
+
21
+Seach by name, namespace or description
22
+
23
+.. code-block:: bash
24
+
25
+    docker search <value>
26
+
27
+
28
+Download them simply by their name
29
+
30
+.. code-block:: bash
31
+
32
+    docker pull <value>
33
+
34
+
35
+Very similarly you can search for and browse the index online on https://index.docker.io
36
+
37
+
38
+Connecting to the repository
39
+----------------------------
40
+
41
+You can create a user on the central docker repository online, or by running
42
+
43
+.. code-block:: bash
44
+
45
+    docker login
46
+
47
+
48
+If your username does not exist it will prompt you to also enter a password and your e-mail address. It will then
49
+automatically log you in.
50
+
51
+
52
+Committing a container to a named image
53
+---------------------------------------
54
+
55
+In order to commit to the repository it is required to have committed your container to an image with your namespace.
56
+
57
+.. code-block:: bash
58
+
59
+    # for example docker commit $CONTAINER_ID dhrp/kickassapp
60
+    docker commit <container_id> <your username>/<some_name>
61
+
62
+
63
+Pushing a container to the repository
64
+-----------------------------------------
65
+
66
+In order to push an image to the repository you need to have committed your container to a named image (see above)
67
+
68
+Now you can commit this image to the repository
69
+
70
+.. code-block:: bash
71
+
72
+    # for example docker push dhrp/kickassapp
73
+    docker push <image-name>
74
+
... ...
@@ -206,6 +206,7 @@
206 206
               } else {
207 207
                   //$('.sidebar > ul > li > ul').slideUp(100);
208 208
                   var current = $(this);
209
+
209 210
                   setTimeout(function() {
210 211
                       $('.sidebar > ul > li').removeClass('current');
211 212
                       current.parent().addClass('current'); // toggle before effect