-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_remote_api_v1.21.apib
More file actions
2127 lines (1593 loc) · 68.1 KB
/
docker_remote_api_v1.21.apib
File metadata and controls
2127 lines (1593 loc) · 68.1 KB
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
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
FORMAT: 1A
# Docker Remote API v1.21
# Group Brief introduction
- The Remote API has replaced `rcli`.
- The daemon listens on `unix:///var/run/docker.sock` but you can [Bind Docker to another host/port or a Unix socket](/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
- The API tends to be REST. However, for some complex commands, like `attach` or `pull`, the HTTP connection is hijacked to transport `stdout`, `stdin` and `stderr`.
- When the client API version is newer than the daemon's, these calls return an HTTP `400 Bad Request` error message.
# Group Endpoints
## Containers [/containers]
### List containers [GET /containers/json{?all,limit,since,before,size,filters}]
Status Codes:
+ 200 - no error
+ 400 - bad parameter
+ 500 - server error
+ Parameters
+ all: 0 (string) - 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default (i.e., this defaults to false)
+ limit (number) - Show `limit` last created containers, include non-running ones.
+ since (string) - Show only containers created since Id, include non-running ones.
+ before: 8dfafdbc3a40 (string) - Show only containers created before Id, include non-running ones.
+ size: 1 (string) - 1/True/true or 0/False/false, Show the containers sizes
+ filters (string) - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
- `exited=<int>`; -- containers with exit code of `<int>` ;
- `status=`(`created`|`restarting`|`running`|`paused`|`exited`)
- `label=key` or `label="key=value"` of a container label
+ Request (application/json)
GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
+ Response 200 (application/json)
[
{
"Id": "8dfafdbc3a40",
"Names":["/boring_feynman"],
"Image": "ubuntu:latest",
"Command": "echo 1",
"Created": 1367854155,
"Status": "Exit 0",
"Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"SizeRw": 12288,
"SizeRootFs": 0
},
{
"Id": "9cd87474be90",
"Names":["/coolName"],
"Image": "ubuntu:latest",
"Command": "echo 222222",
"Created": 1367854155,
"Status": "Exit 0",
"Ports": [],
"Labels": {},
"SizeRw": 12288,
"SizeRootFs": 0
},
{
"Id": "3176a2479c92",
"Names":["/sleepy_dog"],
"Image": "ubuntu:latest",
"Command": "echo 3333333333333333",
"Created": 1367854154,
"Status": "Exit 0",
"Ports":[],
"Labels": {},
"SizeRw":12288,
"SizeRootFs":0
},
{
"Id": "4cb07b47f9fb",
"Names":["/running_cat"],
"Image": "ubuntu:latest",
"Command": "echo 444444444444444444444444444444444",
"Created": 1367854152,
"Status": "Exit 0",
"Ports": [],
"Labels": {},
"SizeRw": 12288,
"SizeRootFs": 0
}
]
### Create a container [POST /containers/create]
Create a container
Status Codes:
+ 201 - no error
+ 404 - no such container
+ 406 - impossible to attach (container not running)
+ 500 - server error
+ Attributes (object)
+ Hostname: null (string) - A string value containing the hostname to use for the container.
+ Domainname (string) - A string value containing the domain name to use for the container.
+ User: null (string) - A string value specifying the user inside the container.
+ Memory: 0 (number) - Memory limit in bytes.
+ MemorySwap: 0 (number) - Total memory limit (memory + swap); set `-1` to disable swap. You must use this with `memory` and make the swap value larger than `memory`.
+ KernelMemory: 0 (number) - Kernel memory limit in bytes.
+ CpuShares: 0 (number) - An integer value containing the container's CPU Shares (ie. the relative weight vs other containers).
+ CpuPeriod: 0 (number) - The length of a CPU period in microseconds.
+ Cpuset: null (number) - Deprecated please don't use. Use `CpusetCpus` instead.
+ CpusetCpus: null (string) - String value containing the `cgroups CpusetCpus` to use.
+ CpusetMems - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
+ BlkioWeight - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
+ MemorySwappiness - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
+ OomKillDisable - Boolean value, whether to disable OOM Killer for the container or not.
+ AttachStdin: false (boolean) - Boolean value, attaches to `stdin`.
+ AttachStdout: true (boolean) - Boolean value, attaches to `stdout`.
+ AttachStderr: true (boolean) - Boolean value, attaches to `stderr`.
+ Tty: false (boolean) - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
+ OpenStdin: false (boolean) - Boolean value, opens stdin.
+ StdinOnce: false (boolean) - Boolean value, close `stdin` after the 1 attached client disconnects.
+ Env: null (string) - A list of environment variables in the form of `VAR=value`
+ Labels: null (string) - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
+ Entrypoint: null (string) - Set the entry point for the container as a string or an array of strings.
+ Image: null (string) - A string specifying the image name to use for the container.
+ Mounts: null (string) - An array of mount points in the container.
+ WorkingDir: null (string) - A string specifying the working directory for commands to run in.
+ NetworkDisabled: null (string) - Boolean value, when true disables networking for the container
+ ExposedPorts: null (string) - An object mapping ports to an empty object in the form of: `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
+ StopSignal: null (string) - Signal to stop a container as a string or unsigned integer. `SIGTERM` by default.
+ HostConfig:
+ Binds: null (string) - A list of volume bindings for this container. Each volume binding is a string in one of these forms:
- `container_path` to create a new volume for the container
- `host_path:container_path` to bind-mount a host path into the container
- `host_path:container_path:ro` to make the bind-mount read-only inside the container.
+ Links: null (string) - A list of links for the container. Each link entry should be in the form of `container_name:alias`.
+ LxcConf: null (string) - LXC specific configurations. These configurations only work when using the `lxc` execution driver.
+ PortBindings: null (string) - A map of exposed container ports and the host port they should map to. A JSON object in the form `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` Take note that `port` is specified as a string and not an integer value.
+ PublishAllPorts: null (string) - Allocates a random host port for all of a container's exposed ports. Specified as a boolean value.
+ Privileged: null (string) - Gives the container full access to the host. Specified as a boolean value.
+ ReadonlyRootfs: null (string) - Mount the container's root filesystem as read only. Specified as a boolean value.
+ Dns: null (string) - A list of DNS servers for the container to use.
+ DnsOptions: null (string) - A list of DNS options
+ DnsSearch: null (string) - A list of DNS search domains
+ ExtraHosts: null (string) - A list of hostnames/IP mappings to add to the container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
+ VolumesFrom: null (string) - A list of volumes to inherit from another container. Specified in the form `<container name>[:<ro|rw>]`
+ CapAdd: null (string) - A list of kernel capabilities to add to the container.
+ Capdrop: null (string) - A list of kernel capabilities to drop from the container.
+ RestartPolicy** – The behavior to apply when the container exits. The value is an object with a `Name` property of either `"always"` to always restart, `"unless-stopped"` to restart always except when user has manually stopped the container or `"on-failure"` to restart only when the container exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` controls the number of times to retry before giving up. The default is not to restart. (optional) An ever increasing delay (double the previous delay, starting at 100mS) is added before each restart to prevent flooding the server.
+ NetworkMode: null (string) - Sets the networking mode for the container. Supported values are: `bridge`, `host`, and `container:<name|id>`
+ Devices: null (string) - A list of devices to add to the container specified as a JSON object in the form `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
+ Ulimits: null (string) - A list of ulimits to set in the container, specified as `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example: `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }`
+ SecurityOpt**: A list of string values to customize labels for MLS systems, such as SELinux.
+ LogConfig: null (string) - Log configuration for the container, specified as a JSON object in the form `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`. Available types: `json-file`, `syslog`, `journald`, `gelf`, `awslogs`, `none`. `json-file` logging driver.
+ CgroupParent: null (string) - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
+ VolumeDriver: null (string) - Driver that this container users to mount volumes.
+ Request (application/json)
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Entrypoint": "",
"Image": "ubuntu",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"Mounts": [
{
"Source": "/data",
"Destination": "/data",
"Mode": "ro,Z",
"RW": false
}
],
"WorkingDir": "",
"NetworkDisabled": false,
"MacAddress": "12:34:56:78:9a:bc",
"ExposedPorts": {
"22/tcp": {}
},
"StopSignal": "SIGTERM",
"HostConfig": {
"Binds": ["/tmp:/tmp"],
"Links": ["redis3:redis"],
"LxcConf": {"lxc.utsname":"docker"},
"Memory": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 512,
"CpuPeriod": 100000,
"CpusetCpus": "0,1",
"CpusetMems": "0,1",
"BlkioWeight": 300,
"MemorySwappiness": 60,
"OomKillDisable": false,
"PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
"PublishAllPorts": false,
"Privileged": false,
"ReadonlyRootfs": false,
"Dns": ["8.8.8.8"],
"DnsOptions": [""],
"DnsSearch": [""],
"ExtraHosts": null,
"VolumesFrom": ["parent", "other:ro"],
"CapAdd": ["NET_ADMIN"],
"CapDrop": ["MKNOD"],
"RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
"NetworkMode": "bridge",
"Devices": [],
"Ulimits": [{}],
"LogConfig": { "Type": "json-file", "Config": {} },
"SecurityOpt": [""],
"CgroupParent": "",
"VolumeDriver": ""
}
}
+ Response 201 (application/json)
{
"Id":"e90e34656806",
"Warnings":[]
}
### Inspect a container [GET /containers/{id}/json]
Return low-level information on the container `id`
Status Codes:
+ 200 - no error
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
GET /containers/4fa6e0f0c678/json HTTP/1.1
+ Response 200 (application/json)
{
"AppArmorProfile": "",
"Args": [
"-c",
"exit 9"
],
"Config": {
"AttachStderr": true,
"AttachStdin": false,
"AttachStdout": true,
"Cmd": [
"/bin/sh",
"-c",
"exit 9"
],
"Domainname": "",
"Entrypoint": null,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": null,
"Hostname": "ba033ac44011",
"Image": "ubuntu",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"MacAddress": "",
"NetworkDisabled": false,
"OnBuild": null,
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": null,
"WorkingDir": "",
"StopSignal": "SIGTERM"
},
"Created": "2015-01-06T15:47:31.485331387Z",
"Driver": "devicemapper",
"ExecDriver": "native-0.2",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"BlkioWeight": 0,
"CapAdd": null,
"CapDrop": null,
"ContainerIDFile": "",
"CpusetCpus": "",
"CpusetMems": "",
"CpuShares": 0,
"CpuPeriod": 100000,
"Devices": [],
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"IpcMode": "",
"Links": null,
"LxcConf": [],
"Memory": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"OomKillDisable": false,
"NetworkMode": "bridge",
"PortBindings": {},
"Privileged": false,
"ReadonlyRootfs": false,
"PublishAllPorts": false,
"RestartPolicy": {
"MaximumRetryCount": 2,
"Name": "on-failure"
},
"LogConfig": {
"Config": null,
"Type": "json-file"
},
"SecurityOpt": null,
"VolumesFrom": null,
"Ulimits": [{}],
"VolumeDriver": ""
},
"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
"MountLabel": "",
"Name": "/boring_euclid",
"NetworkSettings": {
"Bridge": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"MacAddress": "",
"Ports": null
},
"Path": "/bin/sh",
"ProcessLabel": "",
"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
"RestartCount": 1,
"State": {
"Error": "",
"ExitCode": 9,
"FinishedAt": "2015-01-06T15:47:32.080254511Z",
"OOMKilled": false,
"Paused": false,
"Pid": 0,
"Restarting": false,
"Running": true,
"StartedAt": "2015-01-06T15:47:32.072697474Z",
"Status": "running"
},
"Mounts": [
{
"Source": "/data",
"Destination": "/data",
"Mode": "ro,Z",
"RW": false
}
]
}
### List processes running inside a container [GET /containers/{id}/(ps_args)]
List processes running inside the container `id`
Status Codes:
+ 200 – no error
+ 404 – no such container
+ 500 – server error
+ Request (application/json)
GET /containers/4fa6e0f0c678/top HTTP/1.1
+ Response 200 (application/json)
{
"Titles": [
"USER",
"PID",
"%CPU",
"%MEM",
"VSZ",
"RSS",
"TTY",
"STAT",
"START",
"TIME",
"COMMAND"
],
"Processes": [
["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
]
}
+ Parameters
+ id: 4fa6e0f0c678 (string) - container id
+ ps_args: top (string) - ps arguments to use (e.g., aux)
### Get container logs [GET /containers/{id}/logs{?follow,stdout,stderr,since,timestamps,tail}]
Get `stdout` and `stderr` logs from the container ``id``
> **Note**:
> This endpoint works only for containers with `json-file` logging driver.
Status Codes:
+ 101 - no error, hints proxy about hijacking
+ 200 - no error, no upgrade header found
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1
+ Response 101 (application/vnd.docker.raw-stream)
+ Parameters
+ follow: false (string) - 1/True/true or 0/False/false, return stream. Default `false`.
+ stdout: false (string) - 1/True/true or 0/False/false, show `stdout` log. Default `false`.
+ stderr: false (string) - 1/True/true or 0/False/false, show `stderr` log. Default `false`.
+ since: 0 (string) - UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered)
+ timestamps: false (string) - 1/True/true or 0/False/false, print timestamps for every log line. Default `false`.
+ tail: all (string) - Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
### Inspect changes on a container's filesystem [GET /containers/{id}/changes]
Inspect changes on container `id`'s filesystem
Status Codes:
+ 200 - no error
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
GET /containers/4fa6e0f0c678/changes HTTP/1.1
+ Parameters
+ id: 4fa6e0f0c678 (string) - container id
+ Response 200 (application/json)
+ Attributes (object)
+ Path (string)
+ Kind (string) - `0`: Modify, `1`: Add, `2`: Delete
+ Body
[
{
"Path": "/dev",
"Kind": 0
},
{
"Path": "/dev/kmsg",
"Kind": 1
},
{
"Path": "/test",
"Kind": 1
}
]
### Export a container [GET /containers/{id}/export]
Export the contents of container `id`
Status Codes:
+ 200 - no error
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
GET /containers/4fa6e0f0c678/export HTTP/1.1
+ Response 200 (application/json)
{{ TAR STREAM }}
### Get container stats based on resource usage [GET /containers/{id}/stats{?stream}]
This endpoint returns a live stream of a container's resource usage statistics.
> **Note**: this functionality currently only works when using the *libcontainer* exec-driver.
Status Codes:
+ 200 - no error
+ 404 - no such container
+ 500 - server error
+ Request
GET /containers/redis1/stats HTTP/1.1
+ Response 200 (application/json)
{
"read" : "2015-01-08T22:57:31.547920715Z",
"network": {
"eth0": {
"rx_bytes": 5338,
"rx_dropped": 0,
"rx_errors": 0,
"rx_packets": 36,
"tx_bytes": 648,
"tx_dropped": 0,
"tx_errors": 0,
"tx_packets": 8
},
"eth5": {
"rx_bytes": 4641,
"rx_dropped": 0,
"rx_errors": 0,
"rx_packets": 26,
"tx_bytes": 690,
"tx_dropped": 0,
"tx_errors": 0,
"tx_packets": 9
}
},
"memory_stats" : {
"stats" : {
"total_pgmajfault" : 0,
"cache" : 0,
"mapped_file" : 0,
"total_inactive_file" : 0,
"pgpgout" : 414,
"rss" : 6537216,
"total_mapped_file" : 0,
"writeback" : 0,
"unevictable" : 0,
"pgpgin" : 477,
"total_unevictable" : 0,
"pgmajfault" : 0,
"total_rss" : 6537216,
"total_rss_huge" : 6291456,
"total_writeback" : 0,
"total_inactive_anon" : 0,
"rss_huge" : 6291456,
"hierarchical_memory_limit" : 67108864,
"total_pgfault" : 964,
"total_active_file" : 0,
"active_anon" : 6537216,
"total_active_anon" : 6537216,
"total_pgpgout" : 414,
"total_cache" : 0,
"inactive_anon" : 0,
"active_file" : 0,
"pgfault" : 964,
"inactive_file" : 0,
"total_pgpgin" : 477
},
"max_usage" : 6651904,
"usage" : 6537216,
"failcnt" : 0,
"limit" : 67108864
},
"blkio_stats" : {},
"cpu_stats" : {
"cpu_usage" : {
"percpu_usage" : [
16970827,
1839451,
7107380,
10571290
],
"usage_in_usermode" : 10000000,
"total_usage" : 36488948,
"usage_in_kernelmode" : 20000000
},
"system_cpu_usage" : 20091722000000000,
"throttling_data" : {}
}
}
+ Parameters
+ stream: true (string) - 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
### Resize a container TTY [POST /containers/{id}/resize{?h,w}]
Resize the TTY for container with `id`. The unit is number of characters. You must restart the container for the resize to take effect.
Status Codes:
+ 200 - no error
+ 404 - No such container
+ 500 - Cannot resize container
+ Request
POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
+ Response 200 (text/plain; charset=utf-8)
+ Parameters
+ h: 40 (number) - height of `tty` session
+ w: 80 (number) - width
### Start a container [POST /containers/{id}/start]
Start the container `id`
> **Note**:
> For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
> See [create a container](#create-a-container) for details.
Status Codes:
+ 200 - no error
+ 304 - container already started
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
POST /containers/e90e34656806/start HTTP/1.1
+ Response 204 (application/json)
### Stop a container [POST /containers/{id}/stop]
Stop the container `id`
Status Codes:
+ 204 - no error
+ 304 - container already stopped
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
POST /containers/e90e34656806/stop?t=5 HTTP/1.1
+ Response 204 (application/json)
+ Parameters
+ t - number of seconds to wait before killing the container
### Restart a container [POST /containers/{id}/restart{?t}]
Restart the container `id`
Status Codes:
+ 204 - no error
+ 404 - no such container
+ 500 - server error
+ Parameters
+ t - number of seconds to wait before killing the container
+ Response 204 (application/json)
### Kill a container [POST /containers/{id}/kill]
Kill the container `id`
Status Codes:
+ 204 - no error
+ 404 - no such container
+ 500 - server error
+ Parameters:
+ signal (string) - Signal to send to the container: integer or string like `SIGINT`. When not set, `SIGKILL` is assumed and the call waits for the container to exit.
+ Request (application/json)
POST /containers/e90e34656806/kill HTTP/1.1
+ Response 204 (application/json)
### Rename a container [POST /containers/{id}/rename{?name}]
Rename the container `id` to a `new_name`
Status Codes:
+ 204 - no error
+ 404 - no such container
+ 409 - conflict name already assigned
+ 500 - server error
+ Parameters
+ name: new_name (string) - new name for the container
+ Response 204
### Pause a container [POST /containers/{id}/pause]
Pause the container `id`
Status Codes:
+ 204 - no error
+ 404 - no such container
+ 500 - server error
+ Parameters
+ id: e90e34656806 (string)
+ Response 204
### Unpause a container [POST /containers/{id}/unpause]
Unpause the container `id`
Status Codes:
+ 204 - no error
+ 404 - no such container
+ 500 - server error
+ Parameters
+ id: e90e34656806 (string)
+ Response 204
### Attach to a container [POST /containers/{id}/attach{?logs,stream,stdin,stdout,stderr}]
Attach to the container `id`
Status Codes:
+ 101 - no error, hints proxy about hijacking
+ 200 - no error, no upgrade header found
+ 400 - bad parameter
+ 404 - no such container
+ 500 - server error
**Stream details**
When using the TTY setting is enabled in [`POST /containers/create`](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"), the stream is the raw data from the process PTY and client's `stdin`. When the TTY is disabled, then the stream is multiplexed to separate `stdout` and `stderr`.
The format is a **Header** and a **Payload** (frame).
**HEADER**
The header contains the information which the stream writes (`stdout` or
`stderr`). It also contains the size of the associated frame encoded in the
last four bytes (`uint32`).
It is encoded on the first eight bytes like this:
header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
`STREAM_TYPE` can be:
- 0: `stdin` (is written on `stdout`)
- 1: `stdout`
- 2: `stderr`
`SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
the `uint32` size encoded as big endian.
**PAYLOAD**
The payload is the raw stream.
**IMPLEMENTATION**
The simplest way to implement the Attach protocol is the following:
1. Read eight bytes.
2. Choose `stdout` or `stderr` depending on the first byte.
3. Extract the frame size from the last four bytes.
4. Read the extracted size and output it on the correct output.
5. Goto 1.
+ Request (application/json)
POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
+ Response 101 (application/vnd.docker.raw-stream)
+ Parameters
+ logs - 1/True/true or 0/False/false, return logs. Default `false`.
+ stream - 1/True/true or 0/False/false, return stream. Default `false`.
+ stdin - 1/True/true or 0/False/false, if `stream=true`, attach to `stdin`. Default `false`.
+ stdout - 1/True/true or 0/False/false, if `logs=true`, return `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
+ stderr - 1/True/true or 0/False/false, if `logs=true`, return `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
### Attach to a container using websocket [GET /containers/{id}/attach/ws{?logs,stream,stdin,stdout,stderr}]
Attach to the container `id` via websocket
Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
Status Codes:
+ 200 - no error
+ 400 - bad parameter
+ 404 - no such container
+ 500 - server error
+ Response 200
{{ STREAM }}
+ Parameters
+ logs - 1/True/true or 0/False/false, return logs. Default `false`.
+ stream - 1/True/true or 0/False/false, return stream. Default `false`.
+ stdin - 1/True/true or 0/False/false, if `stream=true`, attach to `stdin`. Default `false`.
+ stdout - 1/True/true or 0/False/false, if `logs=true`, return `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
+ stderr - 1/True/true or 0/False/false, if `logs=true`, return `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
### Wait a container [POST /containers/{id}/wait]
Block until container `id` stops, then returns the exit code
Status Codes:
+ 200 - no error
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
POST /containers/16253994b7c4/wait HTTP/1.1
+ Response 200 (application/json)
{"StatusCode": 0}
### Remove a container [DELETE /containers/{id}{?v}]
Remove the container `id` from the filesystem
Status Codes:
+ 204 - no error
+ 400 - bad parameter
+ 404 - no such container
+ 500 - server error
+ Request (application/json)
DELETE /containers/16253994b7c4?v=1 HTTP/1.1
+ Response 204 (application/json)
+ Parameters
+ v - 1/True/true or 0/False/false, Remove the volumes
associated to the container. Default false
### Copy files or folders from a container [POST /containers/{id}/copy]
Copy files or folders of container `id`
**Deprecated** in favor of the `archive` endpoint below.
Status Codes:
+ 200 - no error
+ 404 - no such container
+ 500 - server error
+ Request
POST /containers/4fa6e0f0c678/copy HTTP/1.1
Content-Type: application/json
{
"Resource": "test.txt"
}
+ Response 200 (application/x-tar)
### Retrieving information about files and folders in a container [HEAD /containers/{id}/archive]
See the description of the `X-Docker-Container-Path-Stat` header in the following section.
+ Response 200
### Get an archive of a filesystem resource in a container [GET /containers/{id}/archive{?path}]
Get an tar archive of a resource in the filesystem of container `id`.
Status Codes:
+ 200 - success, returns archive of copied resource
+ 400 - client error, bad parameter, details in JSON response body, one of:
- must specify path parameter (**path** cannot be empty)
- not a directory (**path** was asserted to be a directory but exists as a
file)
+ 404 - client error, resource not found, one of:
– no such container (container `id` does not exist)
- no such file or directory (**path** does not exist)
+ 500 - server error
On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about
the archived resource. The above example value would decode to the following
JSON object (whitespace added for readability):
{
"name": "root",
"size": 4096,
"mode": 2147484096,
"mtime": "2014-02-27T20:51:23Z",
"linkTarget": ""
}
A `HEAD` request can also be made to this endpoint if only this information is desired.
+ Parameters
+ path: /root (string, mandatory) - resource in the container's filesystem to archive
If not an absolute path, it is relative to the container's root directory.
The resource specified by **path** must exist. To assert that the resource
is expected to be a directory, **path** should end in `/` or `/.`
(assuming a path separator of `/`). If **path** ends in `/.` then this
indicates that only the contents of the **path** directory should be
copied. A symlink is always resolved to its target.
**Note**: It is not possible to copy certain system files such as resources
under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
container.
+ Response 200 (application/x-tar)
+ Headers
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
+ Body
{{ TAR STREAM }}
### Extract an archive of files or folders to a directory in a container [PUT /containers/{id}/archive{?path,noOverwriteDirNonDir}]
Upload a tar archive to be extracted to a path in the filesystem of container `id`.
Status Codes: