File
Blob: src/workerd/server/docker-api.capnp
| 1 | # Copyright (c) 2017-2022 Cloudflare, Inc. |
| 2 | # Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | # https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | @0xfafd0bdf57acc528; |
| 6 | using Cxx = import "/capnp/c++.capnp"; |
| 7 | using Json = import "/capnp/compat/json.capnp"; |
| 8 | |
| 9 | $Cxx.namespace("workerd::docker_api"); |
| 10 | $Cxx.allowCancellation; |
| 11 | |
| 12 | struct Docker { |
| 13 | # Docker API structures for container operations |
| 14 | struct LogConfig { |
| 15 | type @0 :Text $Json.name("Type"); |
| 16 | config @1 :Json.Value $Json.name("Config"); |
| 17 | } |
| 18 | |
| 19 | struct RestartPolicy { |
| 20 | name @0 :Text $Json.name("Name"); # "no", "always", "unless-stopped", "on-failure" |
| 21 | maximumRetryCount @1 :UInt32 $Json.name("MaximumRetryCount"); |
| 22 | } |
| 23 | |
| 24 | struct WeightDevice { |
| 25 | path @0 :Text; |
| 26 | weight @1 :UInt16; |
| 27 | } |
| 28 | |
| 29 | struct ThrottleDevice { |
| 30 | path @0 :Text; |
| 31 | rate @1 :UInt64; |
| 32 | } |
| 33 | |
| 34 | struct DeviceMapping { |
| 35 | pathOnHost @0 :Text; |
| 36 | pathInContainer @1 :Text; |
| 37 | cgroupPermissions @2 :Text; |
| 38 | } |
| 39 | |
| 40 | struct DeviceRequest { |
| 41 | driver @0 :Text; |
| 42 | count @1 :Int32; |
| 43 | deviceIds @2 :List(Text); |
| 44 | capabilities @3 :List(List(Text)); |
| 45 | options @4 :Json.Value; |
| 46 | } |
| 47 | |
| 48 | struct Ulimit { |
| 49 | name @0 :Text; |
| 50 | soft @1 :UInt64; |
| 51 | hard @2 :UInt64; |
| 52 | } |
| 53 | |
| 54 | struct IPAMConfig { |
| 55 | ipv4Address @0 :Text $Json.name("IPv4Address"); |
| 56 | ipv6Address @1 :Text $Json.name("IPv6Address"); |
| 57 | linkLocalIps @2 :List(Text) $Json.name("LinkLocalIPs"); |
| 58 | } |
| 59 | |
| 60 | struct EndpointSettings { |
| 61 | ipamConfig @0 :IPAMConfig $Json.name("IPAMConfig"); |
| 62 | links @1 :List(Text) $Json.name("Links"); |
| 63 | aliases @2 :List(Text) $Json.name("Aliases"); |
| 64 | networkId @3 :Text $Json.name("NetworkID"); |
| 65 | endpointId @4 :Text $Json.name("EndpointID"); |
| 66 | gateway @5 :Text $Json.name("Gateway"); |
| 67 | ipAddress @6 :Text $Json.name("IPAddress"); |
| 68 | ipPrefixLen @7 :UInt32 $Json.name("IPPrefixLen"); |
| 69 | ipv6Gateway @8 :Text $Json.name("IPv6Gateway"); |
| 70 | globalIpv6Address @9 :Text $Json.name("GlobalIPv6Address"); |
| 71 | globalIpv6PrefixLen @10 :UInt32 $Json.name("GlobalIPv6PrefixLen"); |
| 72 | macAddress @11 :Text $Json.name("MacAddress"); |
| 73 | driverOpts @12 :Json.Value $Json.name("DriverOpts"); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | struct ContainerCreateRequest { |
| 78 | # Request body for ContainerCreate operation - flattened structure |
| 79 | # Container configuration fields |
| 80 | hostname @0 :Text $Json.name("Hostname"); |
| 81 | domainname @1 :Text $Json.name("Domainname"); |
| 82 | user @2 :Text $Json.name("User"); |
| 83 | attachStdin @3 :Bool = false $Json.name("AttachStdin"); |
| 84 | attachStdout @4 :Bool = false $Json.name("AttachStdout"); |
| 85 | attachStderr @5 :Bool = false $Json.name("AttachStderr"); |
| 86 | exposedPorts @6 :Json.Value $Json.name("ExposedPorts"); # Ports mapped to empty objects |
| 87 | tty @7 :Bool $Json.name("Tty"); |
| 88 | openStdin @8 :Bool $Json.name("OpenStdin"); |
| 89 | stdinOnce @9 :Bool $Json.name("StdinOnce"); |
| 90 | env @10 :List(Text) $Json.name("Env"); # Environment variables in "KEY=value" format |
| 91 | cmd @11 :List(Text) $Json.name("Cmd"); # Command to run |
| 92 | entrypoint @12 :Text $Json.name("Entrypoint"); # Can be string or array - simplified as Text |
| 93 | image @13 :Text $Json.name("Image"); # Image name/reference |
| 94 | labels @14 :Json.Value $Json.name("Labels"); # Labels as key-value pairs |
| 95 | volumes @15 :Json.Value $Json.name("Volumes"); # Volume mount points mapped to empty objects |
| 96 | workingDir @16 :Text $Json.name("WorkingDir"); |
| 97 | networkDisabled @17 :Bool $Json.name("NetworkDisabled"); |
| 98 | macAddress @18 :Text $Json.name("MacAddress"); |
| 99 | stopSignal @19 :Text $Json.name("StopSignal"); |
| 100 | stopTimeout @20 :UInt32 = 10 $Json.name("StopTimeout"); |
| 101 | |
| 102 | # Host configuration |
| 103 | hostConfig @21 :HostConfig $Json.name("HostConfig"); |
| 104 | |
| 105 | # Networking configuration |
| 106 | # networkingConfig @22 :NetworkingConfig $Json.name("NetworkingConfig"); |
| 107 | |
| 108 | struct Mount { |
| 109 | type @0 :Text $Json.name("Type"); |
| 110 | source @1 :Text $Json.name("Source"); |
| 111 | target @2 :Text $Json.name("Target"); |
| 112 | readOnly @3 :Bool = false $Json.name("ReadOnly"); |
| 113 | volumeOptions @4 :VolumeOptions $Json.name("VolumeOptions"); |
| 114 | |
| 115 | struct VolumeOptions { |
| 116 | noCopy @0 :Bool = false $Json.name("NoCopy"); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | struct HostConfig { |
| 121 | # Container configuration that depends on the host |
| 122 | binds @0 :List(Text) $Json.name("Binds"); # Volume bindings |
| 123 | links @1 :List(Text) $Json.name("Links"); |
| 124 | memory @2 :UInt32 $Json.name("Memory"); |
| 125 | memorySwap @3 :UInt32 $Json.name("MemorySwap"); |
| 126 | memoryReservation @4 :UInt32 $Json.name("MemoryReservation"); |
| 127 | kernelMemory @5 :UInt32 $Json.name("KernelMemory"); |
| 128 | nanoCpus @6 :UInt32 $Json.name("NanoCpus"); |
| 129 | cpuPercent @7 :UInt32 $Json.name("CpuPercent"); |
| 130 | cpuShares @8 :UInt32 $Json.name("CpuShares"); |
| 131 | cpuPeriod @9 :UInt32 $Json.name("CpuPeriod"); |
| 132 | cpuRealtimePeriod @10 :UInt32 $Json.name("CpuRealtimePeriod"); |
| 133 | cpuRealtimeRuntime @11 :UInt32 $Json.name("CpuRealtimeRuntime"); |
| 134 | cpuQuota @12 :UInt32 $Json.name("CpuQuota"); |
| 135 | cpusetCpus @13 :Text $Json.name("CpusetCpus"); |
| 136 | cpusetMems @14 :Text $Json.name("CpusetMems"); |
| 137 | maximumIOps @15 :UInt32 $Json.name("MaximumIOps"); |
| 138 | maximumIOBps @16 :UInt32 $Json.name("MaximumIOBps"); |
| 139 | blkioWeight @17 :UInt16 $Json.name("BlkioWeight"); |
| 140 | blkioWeightDevice @18 :List(WeightDevice) $Json.name("BlkioWeightDevice"); |
| 141 | blkioDeviceReadBps @19 :List(ThrottleDevice) $Json.name("BlkioDeviceReadBps"); |
| 142 | blkioDeviceReadIOps @20 :List(ThrottleDevice) $Json.name("BlkioDeviceReadIOps"); |
| 143 | blkioDeviceWriteBps @21 :List(ThrottleDevice) $Json.name("BlkioDeviceWriteBps"); |
| 144 | blkioDeviceWriteIOps @22 :List(ThrottleDevice) $Json.name("BlkioDeviceWriteIOps"); |
| 145 | memorySwappiness @23 :UInt32 $Json.name("MemorySwappiness"); |
| 146 | oomKillDisable @24 :Bool $Json.name("OomKillDisable"); |
| 147 | oomScoreAdj @25 :Int32 $Json.name("OomScoreAdj"); |
| 148 | pidMode @26 :Text $Json.name("PidMode"); |
| 149 | pidsLimit @27 :Int32 $Json.name("PidsLimit"); # Can be -1 |
| 150 | portBindings @28 :Json.Value $Json.name("PortBindings"); # Port bindings map |
| 151 | publishAllPorts @29 :Bool $Json.name("PublishAllPorts"); |
| 152 | privileged @30 :Bool $Json.name("Privileged"); |
| 153 | readonlyRootfs @31 :Bool $Json.name("ReadonlyRootfs"); |
| 154 | dns @32 :List(Text) $Json.name("Dns"); |
| 155 | dnsOptions @33 :List(Text) $Json.name("DnsOptions"); |
| 156 | dnsSearch @34 :List(Text) $Json.name("DnsSearch"); |
| 157 | volumesFrom @35 :List(Text) $Json.name("VolumesFrom"); |
| 158 | capAdd @36 :List(Text) $Json.name("CapAdd"); |
| 159 | capDrop @37 :List(Text) $Json.name("CapDrop"); |
| 160 | groupAdd @38 :List(Text) $Json.name("GroupAdd"); |
| 161 | restartPolicy @39 :RestartPolicy $Json.name("RestartPolicy"); |
| 162 | autoRemove @40 :Bool $Json.name("AutoRemove"); |
| 163 | networkMode @41 :Text $Json.name("NetworkMode"); |
| 164 | devices @42 :List(DeviceMapping) $Json.name("Devices"); |
| 165 | ulimits @43 :List(Ulimit) $Json.name("Ulimits"); |
| 166 | logConfig @44 :LogConfig $Json.name("LogConfig"); |
| 167 | securityOpt @45 :List(Text) $Json.name("SecurityOpt"); |
| 168 | storageOpt @46 :Json.Value $Json.name("StorageOpt"); |
| 169 | cgroupParent @47 :Text $Json.name("CgroupParent"); |
| 170 | volumeDriver @48 :Text $Json.name("VolumeDriver"); |
| 171 | shmSize @49 :UInt32 $Json.name("ShmSize"); |
| 172 | extraHosts @50 :List(Text) $Json.name("ExtraHosts"); # --add-host entries in "host:ip" format |
| 173 | mounts @51 :List(Mount) $Json.name("Mounts"); |
| 174 | |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | struct ContainerCreateResponse { |
| 179 | # Response from ContainerCreate operation |
| 180 | id @0 :Text $Json.name("Id"); # The ID of the created container |
| 181 | warnings @1 :List(Text) $Json.name("Warnings"); # Warnings encountered when creating the container |
| 182 | } |
| 183 | |
| 184 | struct ContainerMonitorResponse { |
| 185 | statusCode @0 :Int32 $Json.name("StatusCode"); |
| 186 | } |
| 187 | |
| 188 | struct ContainerCommitResponse { |
| 189 | id @0 :Text $Json.name("Id"); |
| 190 | } |
| 191 | |
| 192 | struct ContainerState { |
| 193 | # Container's running state |
| 194 | status @0 :Text $Json.name("Status"); # "created", "running", "paused", "restarting", "removing", "exited", "dead" |
| 195 | running @1 :Bool $Json.name("Running"); |
| 196 | paused @2 :Bool $Json.name("Paused"); |
| 197 | restarting @3 :Bool $Json.name("Restarting"); |
| 198 | oomKilled @4 :Bool $Json.name("OOMKilled"); |
| 199 | dead @5 :Bool $Json.name("Dead"); |
| 200 | pid @6 :UInt32 $Json.name("Pid"); |
| 201 | exitCode @7 :Int32 $Json.name("ExitCode"); |
| 202 | error @8 :Text $Json.name("Error"); |
| 203 | startedAt @9 :Text $Json.name("StartedAt"); |
| 204 | finishedAt @10 :Text $Json.name("FinishedAt"); |
| 205 | } |
| 206 | |
| 207 | struct GraphDriverData { |
| 208 | # Information about the storage driver |
| 209 | name @0 :Text $Json.name("Name"); |
| 210 | data @1 :Json.Value $Json.name("Data"); |
| 211 | } |
| 212 | |
| 213 | struct MountPoint { |
| 214 | # Mount point configuration inside the container |
| 215 | type @0 :Text $Json.name("Type"); # "bind", "volume", "tmpfs", "npipe" |
| 216 | name @1 :Text $Json.name("Name"); |
| 217 | source @2 :Text $Json.name("Source"); |
| 218 | destination @3 :Text $Json.name("Destination"); |
| 219 | driver @4 :Text $Json.name("Driver"); |
| 220 | mode @5 :Text $Json.name("Mode"); |
| 221 | rw @6 :Bool $Json.name("RW"); |
| 222 | propagation @7 :Text $Json.name("Propagation"); |
| 223 | } |
| 224 | |
| 225 | struct NetworkSettings { |
| 226 | # Network settings for the container |
| 227 | bridge @0 :Text $Json.name("Bridge"); |
| 228 | sandboxId @1 :Text $Json.name("SandboxID"); |
| 229 | hairpinMode @2 :Bool $Json.name("HairpinMode"); |
| 230 | linkLocalIpv6Address @3 :Text $Json.name("LinkLocalIPv6Address"); |
| 231 | linkLocalIpv6PrefixLen @4 :UInt32 $Json.name("LinkLocalIPv6PrefixLen"); |
| 232 | sandboxKey @5 :Text $Json.name("SandboxKey"); |
| 233 | endpointId @6 :Text $Json.name("EndpointID"); |
| 234 | gateway @7 :Text $Json.name("Gateway"); |
| 235 | globalIpv6Address @8 :Text $Json.name("GlobalIPv6Address"); |
| 236 | globalIpv6PrefixLen @9 :UInt32 $Json.name("GlobalIPv6PrefixLen"); |
| 237 | ipAddress @10 :Text $Json.name("IPAddress"); |
| 238 | ipPrefixLen @11 :UInt32 $Json.name("IPPrefixLen"); |
| 239 | ipv6Gateway @12 :Text $Json.name("IPv6Gateway"); |
| 240 | macAddress @13 :Text $Json.name("MacAddress"); |
| 241 | networks @14 :Json.Value $Json.name("Networks"); |
| 242 | ports @15 :Json.Value $Json.name("Ports"); |
| 243 | } |
| 244 | |
| 245 | struct ContainerConfig { |
| 246 | # Container configuration (reusable from create) |
| 247 | hostname @0 :Text $Json.name("Hostname"); |
| 248 | domainname @1 :Text $Json.name("Domainname"); |
| 249 | user @2 :Text $Json.name("User"); |
| 250 | attachStdin @3 :Bool $Json.name("AttachStdin"); |
| 251 | attachStdout @4 :Bool $Json.name("AttachStdout"); |
| 252 | attachStderr @5 :Bool $Json.name("AttachStderr"); |
| 253 | exposedPorts @6 :Json.Value $Json.name("ExposedPorts"); |
| 254 | tty @7 :Bool $Json.name("Tty"); |
| 255 | openStdin @8 :Bool $Json.name("OpenStdin"); |
| 256 | stdinOnce @9 :Bool $Json.name("StdinOnce"); |
| 257 | env @10 :List(Text) $Json.name("Env"); |
| 258 | cmd @11 :List(Text) $Json.name("Cmd"); |
| 259 | image @12 :Text $Json.name("Image"); |
| 260 | volumes @13 :Json.Value $Json.name("Volumes"); |
| 261 | workingDir @14 :Text $Json.name("WorkingDir"); |
| 262 | entrypoint @15 :List(Text) $Json.name("Entrypoint"); |
| 263 | networkDisabled @16 :Bool $Json.name("NetworkDisabled"); |
| 264 | macAddress @17 :Text $Json.name("MacAddress"); |
| 265 | onBuild @18 :List(Text) $Json.name("OnBuild"); |
| 266 | labels @19 :Json.Value $Json.name("Labels"); |
| 267 | stopSignal @20 :Text $Json.name("StopSignal"); |
| 268 | stopTimeout @21 :UInt32 $Json.name("StopTimeout"); |
| 269 | shell @22 :List(Text) $Json.name("Shell"); |
| 270 | } |
| 271 | |
| 272 | struct ContainerInspectResponse { |
| 273 | # Response from ContainerInspect operation |
| 274 | id @0 :Text $Json.name("Id"); |
| 275 | created @1 :Text $Json.name("Created"); |
| 276 | path @2 :Text $Json.name("Path"); |
| 277 | args @3 :List(Text) $Json.name("Args"); |
| 278 | state @4 :ContainerState $Json.name("State"); |
| 279 | networkSettings @5 :NetworkSettings $Json.name("NetworkSettings"); |
| 280 | config @6 :ContainerConfig $Json.name("Config"); |
| 281 | } |
| 282 | |
| 283 | struct ImageInspectResponse { |
| 284 | id @0 :Text $Json.name("Id"); |
| 285 | size @1 :UInt64 $Json.name("Size"); |
| 286 | } |
| 287 | |
| 288 | struct ExecCreateRequest { |
| 289 | attachStdin @0 :Bool = false $Json.name("AttachStdin"); |
| 290 | attachStdout @1 :Bool = false $Json.name("AttachStdout"); |
| 291 | attachStderr @2 :Bool = false $Json.name("AttachStderr"); |
| 292 | tty @3 :Bool = false $Json.name("Tty"); |
| 293 | cmd @4 :List(Text) $Json.name("Cmd"); |
| 294 | env @5 :List(Text) $Json.name("Env"); |
| 295 | workingDir @6 :Text $Json.name("WorkingDir"); |
| 296 | user @7 :Text $Json.name("User"); |
| 297 | } |
| 298 | |
| 299 | struct ExecCreateResponse { |
| 300 | id @0 :Text $Json.name("Id"); |
| 301 | } |
| 302 | |
| 303 | struct ExecStartRequest { |
| 304 | detach @0 :Bool = false $Json.name("Detach"); |
| 305 | tty @1 :Bool = false $Json.name("Tty"); |
| 306 | } |
| 307 | |
| 308 | struct ExecInspectResponse { |
| 309 | canRemove @0 :Bool $Json.name("CanRemove"); |
| 310 | detachKeys @1 :Text $Json.name("DetachKeys"); |
| 311 | exitCode @2 :Json.Value $Json.name("ExitCode"); |
| 312 | id @3 :Text $Json.name("ID"); |
| 313 | openStderr @4 :Bool $Json.name("OpenStderr"); |
| 314 | openStdin @5 :Bool $Json.name("OpenStdin"); |
| 315 | openStdout @6 :Bool $Json.name("OpenStdout"); |
| 316 | processConfig @7 :Json.Value $Json.name("ProcessConfig"); |
| 317 | running @8 :Bool $Json.name("Running"); |
| 318 | pid @9 :UInt32 $Json.name("Pid"); |
| 319 | } |
| 320 | |
| 321 | struct Command { |
| 322 | struct ContainerCreate { |
| 323 | struct Params { |
| 324 | name @0 :Text; # Optional container name |
| 325 | body @1 :ContainerCreateRequest; |
| 326 | } |
| 327 | struct Result { |
| 328 | response @0 :ContainerCreateResponse; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | struct ContainerInspect { |
| 333 | struct Params { |
| 334 | id @0 :Text; # Container ID or name |
| 335 | } |
| 336 | struct Result { |
| 337 | response @0 :ContainerInspectResponse; |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | # Network inspection response (GET /networks/{id}) |
| 343 | struct NetworkInspectResponse { |
| 344 | name @0 :Text $Json.name("Name"); |
| 345 | id @1 :Text $Json.name("Id"); |
| 346 | ipam @2 :IPAM $Json.name("IPAM"); |
| 347 | |
| 348 | struct IPAM { |
| 349 | driver @0 :Text $Json.name("Driver"); |
| 350 | config @1 :List(IPAMConfig) $Json.name("Config"); |
| 351 | |
| 352 | struct IPAMConfig { |
| 353 | subnet @0 :Text $Json.name("Subnet"); |
| 354 | gateway @1 :Text $Json.name("Gateway"); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | # Network create request (POST /networks/create) |
| 360 | # Equivalent to: docker network create -d bridge --ipv6 workerd-network |
| 361 | struct NetworkCreateRequest { |
| 362 | name @0 :Text $Json.name("Name"); |
| 363 | driver @1 :Text $Json.name("Driver"); # "bridge", "overlay", etc. |
| 364 | enableIpv6 @2 :Bool $Json.name("EnableIPv6"); |
| 365 | } |
| 366 | |
| 367 | # Network create response |
| 368 | struct NetworkCreateResponse { |
| 369 | id @0 :Text $Json.name("Id"); |
| 370 | warning @1 :Text $Json.name("Warning"); |
| 371 | } |
| 372 | |
| 373 | # Volume create request (POST /volumes/create) |
| 374 | struct VolumeCreateRequest { |
| 375 | name @0 :Text $Json.name("Name"); |
| 376 | labels @1 :Json.Value $Json.name("Labels"); |
| 377 | } |
| 378 | |
| 379 | # Volume list filters query parameter (GET /volumes?filters=...) |
| 380 | struct VolumeListFilters { |
| 381 | name @0 :List(Text) $Json.name("name"); |
| 382 | } |
| 383 | |
| 384 | # Volume list response (GET /volumes) |
| 385 | struct VolumeListResponse { |
| 386 | volumes @0 :List(Volume) $Json.name("Volumes"); |
| 387 | warnings @1 :List(Text) $Json.name("Warnings"); |
| 388 | |
| 389 | struct Volume { |
| 390 | name @0 :Text $Json.name("Name"); |
| 391 | labels @1 :Json.Value $Json.name("Labels"); |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | struct ProxyEverything { |
| 397 | struct Dns { |
| 398 | allowHostnames @0 :List(Text) $Json.name("allowHostnames"); |
| 399 | } |
| 400 | |
| 401 | struct Internet { |
| 402 | enabled @0 :Bool $Json.name("enabled"); |
| 403 | } |
| 404 | |
| 405 | struct Port { |
| 406 | port @0 :UInt16 $Json.name("port"); |
| 407 | dns @1 :Dns $Json.name("dns"); |
| 408 | internet @2 :Internet $Json.name("internet"); |
| 409 | } |
| 410 | } |