summaryrefslogtreecommitdiff
path: root/docs/sources/reference/api/docker-io_api.md
blob: d5be332d357ef76273464c6772dfbf52fd003999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
page_title: Docker Hub API
page_description: API Documentation for the Docker Hub API
page_keywords: API, Docker, index, REST, documentation, Docker Hub, registry

# Docker Hub API

## Introduction

- This is the REST API for [Docker Hub](https://hub.docker.com).
- Authorization is done with basic auth over SSL
- Not all commands require authentication, only those noted as such.

## Repository

### Repositories

#### User Repo

`PUT /v1/repositories/(namespace)/(repo_name)/`

Create a user repository with the given `namespace` and `repo_name`.

    **Example Request**:

        PUT /v1/repositories/foo/bar/ HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==
        X-Docker-Token: true

        [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"}]

    Parameters:

    - **namespace** – the namespace for the repo
    - **repo_name** – the name for the repo

    **Example Response**:

        HTTP/1.1 200
        Vary: Accept
        Content-Type: application/json
        WWW-Authenticate: Token signature=123abc,repository="foo/bar",access=write
        X-Docker-Token: signature=123abc,repository="foo/bar",access=write
        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]

        ""

    Status Codes:

    - **200** – Created
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active

`DELETE /v1/repositories/(namespace)/(repo_name)/`

Delete a user repository with the given `namespace` and `repo_name`.

    **Example Request**:

        DELETE /v1/repositories/foo/bar/ HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==
        X-Docker-Token: true

        ""

    Parameters:

    - **namespace** – the namespace for the repo
    - **repo_name** – the name for the repo

    **Example Response**:

        HTTP/1.1 202
        Vary: Accept
        Content-Type: application/json
        WWW-Authenticate: Token signature=123abc,repository="foo/bar",access=delete
        X-Docker-Token: signature=123abc,repository="foo/bar",access=delete
        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]

        ""

    Status Codes:

    - **200** – Deleted
    - **202** – Accepted
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active

#### Library Repo

`PUT /v1/repositories/(repo_name)/`

Create a library repository with the given `repo_name`.
This is a restricted feature only available to docker admins.

    When namespace is missing, it is assumed to be `library`


    **Example Request**:

        PUT /v1/repositories/foobar/ HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==
        X-Docker-Token: true

        [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"}]

    Parameters:

    - **repo_name** – the library name for the repo

    **Example Response**:

        HTTP/1.1 200
        Vary: Accept
        Content-Type: application/json
        WWW-Authenticate: Token signature=123abc,repository="library/foobar",access=write
        X-Docker-Token: signature=123abc,repository="foo/bar",access=write
        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]

        ""

    Status Codes:

    - **200** – Created
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active

`DELETE /v1/repositories/(repo_name)/`

Delete a library repository with the given `repo_name`. 
This is a restricted feature only available to docker admins.

    When namespace is missing, it is assumed to be `library`


    **Example Request**:

        DELETE /v1/repositories/foobar/ HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==
        X-Docker-Token: true

        ""

    Parameters:

    - **repo_name** – the library name for the repo

    **Example Response**:

        HTTP/1.1 202
        Vary: Accept
        Content-Type: application/json
        WWW-Authenticate: Token signature=123abc,repository="library/foobar",access=delete
        X-Docker-Token: signature=123abc,repository="foo/bar",access=delete
        X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]

        ""

    Status Codes:

    - **200** – Deleted
    - **202** – Accepted
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active

### Repository Images

#### User Repo Images

`PUT /v1/repositories/(namespace)/(repo_name)/images`

Update the images for a user repo.

    **Example Request**:

        PUT /v1/repositories/foo/bar/images HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==

        [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
        "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}]

    Parameters:

    - **namespace** – the namespace for the repo
    - **repo_name** – the name for the repo

    **Example Response**:

        HTTP/1.1 204
        Vary: Accept
        Content-Type: application/json

        ""

    Status Codes:

    - **204** – Created
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active or permission denied

`GET /v1/repositories/(namespace)/(repo_name)/images`

Get the images for a user repo.

    **Example Request**:

        GET /v1/repositories/foo/bar/images HTTP/1.1
        Host: index.docker.io
        Accept: application/json

    Parameters:

    - **namespace** – the namespace for the repo
    - **repo_name** – the name for the repo

    **Example Response**:

        HTTP/1.1 200
        Vary: Accept
        Content-Type: application/json

        [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
        "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"},
        {"id": "ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds",
        "checksum": "34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew"}]

    Status Codes:

    - **200** – OK
    - **404** – Not found

#### Library Repo Images

`PUT /v1/repositories/(repo_name)/images`

Update the images for a library repo.

    **Example Request**:

        PUT /v1/repositories/foobar/images HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==

        [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
        "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}]

    Parameters:

    - **repo_name** – the library name for the repo

    **Example Response**:

        HTTP/1.1 204
        Vary: Accept
        Content-Type: application/json

        ""

    Status Codes:

    - **204** – Created
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active or permission denied

`GET /v1/repositories/(repo_name)/images`

Get the images for a library repo.

    **Example Request**:

        GET /v1/repositories/foobar/images HTTP/1.1
        Host: index.docker.io
        Accept: application/json

    Parameters:

    - **repo_name** – the library name for the repo

    **Example Response**:

        HTTP/1.1 200
        Vary: Accept
        Content-Type: application/json

        [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
        "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"},
        {"id": "ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds",
        "checksum": "34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew"}]

    Status Codes:

    - **200** – OK
    - **404** – Not found

### Repository Authorization

#### Library Repo

`PUT /v1/repositories/(repo_name)/auth`

Authorize a token for a library repo

    **Example Request**:

        PUT /v1/repositories/foobar/auth HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Authorization: Token signature=123abc,repository="library/foobar",access=write

    Parameters:

    - **repo_name** – the library name for the repo

    **Example Response**:

        HTTP/1.1 200
        Vary: Accept
        Content-Type: application/json

        "OK"

    Status Codes:

    - **200** – OK
    - **403** – Permission denied
    - **404** – Not found

#### User Repo

`PUT /v1/repositories/(namespace)/(repo_name)/auth`

Authorize a token for a user repo

    **Example Request**:

        PUT /v1/repositories/foo/bar/auth HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Authorization: Token signature=123abc,repository="foo/bar",access=write

    Parameters:

    - **namespace** – the namespace for the repo
    - **repo_name** – the name for the repo

    **Example Response**:

        HTTP/1.1 200
        Vary: Accept
        Content-Type: application/json

        "OK"

    Status Codes:

    - **200** – OK
    - **403** – Permission denied
    - **404** – Not found

### Users

#### User Login

`GET /v1/users`

If you want to check your login, you can try this endpoint

    **Example Request**:

        GET /v1/users HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Authorization: Basic akmklmasadalkm==

    **Example Response**:

        HTTP/1.1 200 OK
        Vary: Accept
        Content-Type: application/json

        OK

    Status Codes:

    - **200** – no error
    - **401** – Unauthorized
    - **403** – Account is not Active

#### User Register

`POST /v1/users`

Registering a new account.

    **Example request**:

        POST /v1/users HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json

        {"email": "sam@dotcloud.com",
         "password": "toto42",
         "username": "foobar"}

    Json Parameters:

     

    - **email** – valid email address, that needs to be confirmed
    - **username** – min 4 character, max 30 characters, must match
        the regular expression [a-z0-9_].
    - **password** – min 5 characters

    **Example Response**:

        HTTP/1.1 201 OK
        Vary: Accept
        Content-Type: application/json

        "User Created"

    Status Codes:

    - **201** – User Created
    - **400** – Errors (invalid json, missing or invalid fields, etc)

#### Update User

`PUT /v1/users/(username)/`

Change a password or email address for given user. If you pass in an

    email, it will add it to your account, it will not remove the old
    one. Passwords will be updated.

    It is up to the client to verify that that password that is sent is
    the one that they want. Common approach is to have them type it
    twice.

    **Example Request**:

        PUT /v1/users/fakeuser/ HTTP/1.1
        Host: index.docker.io
        Accept: application/json
        Content-Type: application/json
        Authorization: Basic akmklmasadalkm==

        {"email": "sam@dotcloud.com",
         "password": "toto42"}

    Parameters:

    - **username** – username for the person you want to update

    **Example Response**:

        HTTP/1.1 204
        Vary: Accept
        Content-Type: application/json

        ""

    Status Codes:

    - **204** – User Updated
    - **400** – Errors (invalid json, missing or invalid fields, etc)
    - **401** – Unauthorized
    - **403** – Account is not Active
    - **404** – User not found

## Search

If you need to search the index, this is the endpoint you would use.

### Search

`GET /v1/search`

Search the Index given a search term. It accepts

    [GET](http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3)
    only.

    **Example request**:

        GET /v1/search?q=search_term HTTP/1.1
        Host: example.com
        Accept: application/json

    **Example response**:

        HTTP/1.1 200 OK
        Vary: Accept
        Content-Type: application/json

        {"query":"search_term",
          "num_results": 3,
          "results" : [
             {"name": "ubuntu", "description": "An ubuntu image..."},
             {"name": "centos", "description": "A centos image..."},
             {"name": "fedora", "description": "A fedora image..."}
           ]
         }

    Query Parameters:

    - **q** – what you want to search for

    Status Codes:

    - **200** – no error
    - **500** – server error