types.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. package types
  2. import (
  3. "io"
  4. "os"
  5. "time"
  6. "github.com/docker/docker/api/types/container"
  7. "github.com/docker/docker/api/types/filters"
  8. "github.com/docker/docker/api/types/mount"
  9. "github.com/docker/docker/api/types/network"
  10. "github.com/docker/docker/api/types/registry"
  11. "github.com/docker/docker/api/types/swarm"
  12. "github.com/docker/go-connections/nat"
  13. )
  14. // ContainerChange contains response of Remote API:
  15. // GET "/containers/{name:.*}/changes"
  16. type ContainerChange struct {
  17. Kind int
  18. Path string
  19. }
  20. // ImageHistory contains response of Remote API:
  21. // GET "/images/{name:.*}/history"
  22. type ImageHistory struct {
  23. ID string `json:"Id"`
  24. Created int64
  25. CreatedBy string
  26. Tags []string
  27. Size int64
  28. Comment string
  29. }
  30. // ImageDelete contains response of Remote API:
  31. // DELETE "/images/{name:.*}"
  32. type ImageDelete struct {
  33. Untagged string `json:",omitempty"`
  34. Deleted string `json:",omitempty"`
  35. }
  36. // GraphDriverData returns Image's graph driver config info
  37. // when calling inspect command
  38. type GraphDriverData struct {
  39. Name string
  40. Data map[string]string
  41. }
  42. // RootFS returns Image's RootFS description including the layer IDs.
  43. type RootFS struct {
  44. Type string
  45. Layers []string `json:",omitempty"`
  46. BaseLayer string `json:",omitempty"`
  47. }
  48. // ImageInspect contains response of Remote API:
  49. // GET "/images/{name:.*}/json"
  50. type ImageInspect struct {
  51. ID string `json:"Id"`
  52. RepoTags []string
  53. RepoDigests []string
  54. Parent string
  55. Comment string
  56. Created string
  57. Container string
  58. ContainerConfig *container.Config
  59. DockerVersion string
  60. Author string
  61. Config *container.Config
  62. Architecture string
  63. Os string
  64. OsVersion string `json:",omitempty"`
  65. Size int64
  66. VirtualSize int64
  67. GraphDriver GraphDriverData
  68. RootFS RootFS
  69. }
  70. // Container contains response of Remote API:
  71. // GET "/containers/json"
  72. type Container struct {
  73. ID string `json:"Id"`
  74. Names []string
  75. Image string
  76. ImageID string
  77. Command string
  78. Created int64
  79. Ports []Port
  80. SizeRw int64 `json:",omitempty"`
  81. SizeRootFs int64 `json:",omitempty"`
  82. Labels map[string]string
  83. State string
  84. Status string
  85. HostConfig struct {
  86. NetworkMode string `json:",omitempty"`
  87. }
  88. NetworkSettings *SummaryNetworkSettings
  89. Mounts []MountPoint
  90. }
  91. // CopyConfig contains request body of Remote API:
  92. // POST "/containers/"+containerID+"/copy"
  93. type CopyConfig struct {
  94. Resource string
  95. }
  96. // ContainerPathStat is used to encode the header from
  97. // GET "/containers/{name:.*}/archive"
  98. // "Name" is the file or directory name.
  99. type ContainerPathStat struct {
  100. Name string `json:"name"`
  101. Size int64 `json:"size"`
  102. Mode os.FileMode `json:"mode"`
  103. Mtime time.Time `json:"mtime"`
  104. LinkTarget string `json:"linkTarget"`
  105. }
  106. // ContainerStats contains response of Remote API:
  107. // GET "/stats"
  108. type ContainerStats struct {
  109. Body io.ReadCloser `json:"body"`
  110. OSType string `json:"ostype"`
  111. }
  112. // ContainerProcessList contains response of Remote API:
  113. // GET "/containers/{name:.*}/top"
  114. type ContainerProcessList struct {
  115. Processes [][]string
  116. Titles []string
  117. }
  118. // Ping contains response of Remote API:
  119. // GET "/_ping"
  120. type Ping struct {
  121. APIVersion string
  122. Experimental bool
  123. }
  124. // Version contains response of Remote API:
  125. // GET "/version"
  126. type Version struct {
  127. Version string
  128. APIVersion string `json:"ApiVersion"`
  129. MinAPIVersion string `json:"MinAPIVersion,omitempty"`
  130. GitCommit string
  131. GoVersion string
  132. Os string
  133. Arch string
  134. KernelVersion string `json:",omitempty"`
  135. Experimental bool `json:",omitempty"`
  136. BuildTime string `json:",omitempty"`
  137. }
  138. // Commit records a external tool actual commit id version along the
  139. // one expect by dockerd as set at build time
  140. type Commit struct {
  141. ID string
  142. Expected string
  143. }
  144. // InfoBase contains the base response of Remote API:
  145. // GET "/info"
  146. type InfoBase struct {
  147. ID string
  148. Containers int
  149. ContainersRunning int
  150. ContainersPaused int
  151. ContainersStopped int
  152. Images int
  153. Driver string
  154. DriverStatus [][2]string
  155. SystemStatus [][2]string
  156. Plugins PluginsInfo
  157. MemoryLimit bool
  158. SwapLimit bool
  159. KernelMemory bool
  160. CPUCfsPeriod bool `json:"CpuCfsPeriod"`
  161. CPUCfsQuota bool `json:"CpuCfsQuota"`
  162. CPUShares bool
  163. CPUSet bool
  164. IPv4Forwarding bool
  165. BridgeNfIptables bool
  166. BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
  167. Debug bool
  168. NFd int
  169. OomKillDisable bool
  170. NGoroutines int
  171. SystemTime string
  172. LoggingDriver string
  173. CgroupDriver string
  174. NEventsListener int
  175. KernelVersion string
  176. OperatingSystem string
  177. OSType string
  178. Architecture string
  179. IndexServerAddress string
  180. RegistryConfig *registry.ServiceConfig
  181. NCPU int
  182. MemTotal int64
  183. DockerRootDir string
  184. HTTPProxy string `json:"HttpProxy"`
  185. HTTPSProxy string `json:"HttpsProxy"`
  186. NoProxy string
  187. Name string
  188. Labels []string
  189. ExperimentalBuild bool
  190. ServerVersion string
  191. ClusterStore string
  192. ClusterAdvertise string
  193. Runtimes map[string]Runtime
  194. DefaultRuntime string
  195. Swarm swarm.Info
  196. // LiveRestoreEnabled determines whether containers should be kept
  197. // running when the daemon is shutdown or upon daemon start if
  198. // running containers are detected
  199. LiveRestoreEnabled bool
  200. Isolation container.Isolation
  201. InitBinary string
  202. ContainerdCommit Commit
  203. RuncCommit Commit
  204. InitCommit Commit
  205. }
  206. // SecurityOpt holds key/value pair about a security option
  207. type SecurityOpt struct {
  208. Key, Value string
  209. }
  210. // Info contains response of Remote API:
  211. // GET "/info"
  212. type Info struct {
  213. *InfoBase
  214. SecurityOptions []SecurityOpt
  215. }
  216. // PluginsInfo is a temp struct holding Plugins name
  217. // registered with docker daemon. It is used by Info struct
  218. type PluginsInfo struct {
  219. // List of Volume plugins registered
  220. Volume []string
  221. // List of Network plugins registered
  222. Network []string
  223. // List of Authorization plugins registered
  224. Authorization []string
  225. }
  226. // ExecStartCheck is a temp struct used by execStart
  227. // Config fields is part of ExecConfig in runconfig package
  228. type ExecStartCheck struct {
  229. // ExecStart will first check if it's detached
  230. Detach bool
  231. // Check if there's a tty
  232. Tty bool
  233. }
  234. // HealthcheckResult stores information about a single run of a healthcheck probe
  235. type HealthcheckResult struct {
  236. Start time.Time // Start is the time this check started
  237. End time.Time // End is the time this check ended
  238. ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe
  239. Output string // Output from last check
  240. }
  241. // Health states
  242. const (
  243. NoHealthcheck = "none" // Indicates there is no healthcheck
  244. Starting = "starting" // Starting indicates that the container is not yet ready
  245. Healthy = "healthy" // Healthy indicates that the container is running correctly
  246. Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem
  247. )
  248. // Health stores information about the container's healthcheck results
  249. type Health struct {
  250. Status string // Status is one of Starting, Healthy or Unhealthy
  251. FailingStreak int // FailingStreak is the number of consecutive failures
  252. Log []*HealthcheckResult // Log contains the last few results (oldest first)
  253. }
  254. // ContainerState stores container's running state
  255. // it's part of ContainerJSONBase and will return by "inspect" command
  256. type ContainerState struct {
  257. Status string
  258. Running bool
  259. Paused bool
  260. Restarting bool
  261. OOMKilled bool
  262. Dead bool
  263. Pid int
  264. ExitCode int
  265. Error string
  266. StartedAt string
  267. FinishedAt string
  268. Health *Health `json:",omitempty"`
  269. }
  270. // ContainerNode stores information about the node that a container
  271. // is running on. It's only available in Docker Swarm
  272. type ContainerNode struct {
  273. ID string
  274. IPAddress string `json:"IP"`
  275. Addr string
  276. Name string
  277. Cpus int
  278. Memory int64
  279. Labels map[string]string
  280. }
  281. // ContainerJSONBase contains response of Remote API:
  282. // GET "/containers/{name:.*}/json"
  283. type ContainerJSONBase struct {
  284. ID string `json:"Id"`
  285. Created string
  286. Path string
  287. Args []string
  288. State *ContainerState
  289. Image string
  290. ResolvConfPath string
  291. HostnamePath string
  292. HostsPath string
  293. LogPath string
  294. Node *ContainerNode `json:",omitempty"`
  295. Name string
  296. RestartCount int
  297. Driver string
  298. MountLabel string
  299. ProcessLabel string
  300. AppArmorProfile string
  301. ExecIDs []string
  302. HostConfig *container.HostConfig
  303. GraphDriver GraphDriverData
  304. SizeRw *int64 `json:",omitempty"`
  305. SizeRootFs *int64 `json:",omitempty"`
  306. }
  307. // ContainerJSON is newly used struct along with MountPoint
  308. type ContainerJSON struct {
  309. *ContainerJSONBase
  310. Mounts []MountPoint
  311. Config *container.Config
  312. NetworkSettings *NetworkSettings
  313. }
  314. // NetworkSettings exposes the network settings in the api
  315. type NetworkSettings struct {
  316. NetworkSettingsBase
  317. DefaultNetworkSettings
  318. Networks map[string]*network.EndpointSettings
  319. }
  320. // SummaryNetworkSettings provides a summary of container's networks
  321. // in /containers/json
  322. type SummaryNetworkSettings struct {
  323. Networks map[string]*network.EndpointSettings
  324. }
  325. // NetworkSettingsBase holds basic information about networks
  326. type NetworkSettingsBase struct {
  327. Bridge string // Bridge is the Bridge name the network uses(e.g. `docker0`)
  328. SandboxID string // SandboxID uniquely represents a container's network stack
  329. HairpinMode bool // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
  330. LinkLocalIPv6Address string // LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix
  331. LinkLocalIPv6PrefixLen int // LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address
  332. Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port
  333. SandboxKey string // SandboxKey identifies the sandbox
  334. SecondaryIPAddresses []network.Address
  335. SecondaryIPv6Addresses []network.Address
  336. }
  337. // DefaultNetworkSettings holds network information
  338. // during the 2 release deprecation period.
  339. // It will be removed in Docker 1.11.
  340. type DefaultNetworkSettings struct {
  341. EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox
  342. Gateway string // Gateway holds the gateway address for the network
  343. GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address
  344. GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
  345. IPAddress string // IPAddress holds the IPv4 address for the network
  346. IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address
  347. IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6
  348. MacAddress string // MacAddress holds the MAC address for the network
  349. }
  350. // MountPoint represents a mount point configuration inside the container.
  351. // This is used for reporting the mountpoints in use by a container.
  352. type MountPoint struct {
  353. Type mount.Type `json:",omitempty"`
  354. Name string `json:",omitempty"`
  355. Source string
  356. Destination string
  357. Driver string `json:",omitempty"`
  358. Mode string
  359. RW bool
  360. Propagation mount.Propagation
  361. }
  362. // NetworkResource is the body of the "get network" http response message
  363. type NetworkResource struct {
  364. Name string // Name is the requested name of the network
  365. ID string `json:"Id"` // ID uniquely identifies a network on a single machine
  366. Created time.Time // Created is the time the network created
  367. Scope string // Scope describes the level at which the network exists (e.g. `global` for cluster-wide or `local` for machine level)
  368. Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
  369. EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6
  370. IPAM network.IPAM // IPAM is the network's IP Address Management
  371. Internal bool // Internal represents if the network is used internal only
  372. Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
  373. Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
  374. Options map[string]string // Options holds the network specific options to use for when creating the network
  375. Labels map[string]string // Labels holds metadata specific to the network being created
  376. Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
  377. }
  378. // EndpointResource contains network resources allocated and used for a container in a network
  379. type EndpointResource struct {
  380. Name string
  381. EndpointID string
  382. MacAddress string
  383. IPv4Address string
  384. IPv6Address string
  385. }
  386. // NetworkCreate is the expected body of the "create network" http request message
  387. type NetworkCreate struct {
  388. CheckDuplicate bool
  389. Driver string
  390. EnableIPv6 bool
  391. IPAM *network.IPAM
  392. Internal bool
  393. Attachable bool
  394. Options map[string]string
  395. Labels map[string]string
  396. }
  397. // NetworkCreateRequest is the request message sent to the server for network create call.
  398. type NetworkCreateRequest struct {
  399. NetworkCreate
  400. Name string
  401. }
  402. // NetworkCreateResponse is the response message sent by the server for network create call
  403. type NetworkCreateResponse struct {
  404. ID string `json:"Id"`
  405. Warning string
  406. }
  407. // NetworkConnect represents the data to be used to connect a container to the network
  408. type NetworkConnect struct {
  409. Container string
  410. EndpointConfig *network.EndpointSettings `json:",omitempty"`
  411. }
  412. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  413. type NetworkDisconnect struct {
  414. Container string
  415. Force bool
  416. }
  417. // Checkpoint represents the details of a checkpoint
  418. type Checkpoint struct {
  419. Name string // Name is the name of the checkpoint
  420. }
  421. // Runtime describes an OCI runtime
  422. type Runtime struct {
  423. Path string `json:"path"`
  424. Args []string `json:"runtimeArgs,omitempty"`
  425. }
  426. // DiskUsage contains response of Remote API:
  427. // GET "/system/df"
  428. type DiskUsage struct {
  429. LayersSize int64
  430. Images []*ImageSummary
  431. Containers []*Container
  432. Volumes []*Volume
  433. }
  434. // ImagesPruneConfig contains the configuration for Remote API:
  435. // POST "/images/prune"
  436. type ImagesPruneConfig struct {
  437. DanglingOnly bool
  438. }
  439. // ContainersPruneConfig contains the configuration for Remote API:
  440. // POST "/images/prune"
  441. type ContainersPruneConfig struct {
  442. }
  443. // VolumesPruneConfig contains the configuration for Remote API:
  444. // POST "/images/prune"
  445. type VolumesPruneConfig struct {
  446. }
  447. // NetworksPruneConfig contains the configuration for Remote API:
  448. // POST "/networks/prune"
  449. type NetworksPruneConfig struct {
  450. }
  451. // ContainersPruneReport contains the response for Remote API:
  452. // POST "/containers/prune"
  453. type ContainersPruneReport struct {
  454. ContainersDeleted []string
  455. SpaceReclaimed uint64
  456. }
  457. // VolumesPruneReport contains the response for Remote API:
  458. // POST "/volumes/prune"
  459. type VolumesPruneReport struct {
  460. VolumesDeleted []string
  461. SpaceReclaimed uint64
  462. }
  463. // ImagesPruneReport contains the response for Remote API:
  464. // POST "/images/prune"
  465. type ImagesPruneReport struct {
  466. ImagesDeleted []ImageDelete
  467. SpaceReclaimed uint64
  468. }
  469. // NetworksPruneReport contains the response for Remote API:
  470. // POST "/networks/prune"
  471. type NetworksPruneReport struct {
  472. NetworksDeleted []string
  473. }
  474. // SecretCreateResponse contains the information returned to a client
  475. // on the creation of a new secret.
  476. type SecretCreateResponse struct {
  477. // ID is the id of the created secret.
  478. ID string
  479. }
  480. // SecretListOptions holds parameters to list secrets
  481. type SecretListOptions struct {
  482. Filters filters.Args
  483. }