tree: b8ab85c6c6a4f526d8e7cd8fcb54ecfbf114630f [path history] [tgz]
  1. testdata/
  2. checkpoint_create.go
  3. checkpoint_create_test.go
  4. checkpoint_delete.go
  5. checkpoint_delete_test.go
  6. checkpoint_list.go
  7. checkpoint_list_test.go
  8. client.go
  9. client_mock_test.go
  10. client_test.go
  11. client_unix.go
  12. client_windows.go
  13. container_attach.go
  14. container_commit.go
  15. container_commit_test.go
  16. container_copy.go
  17. container_copy_test.go
  18. container_create.go
  19. container_create_test.go
  20. container_diff.go
  21. container_diff_test.go
  22. container_exec.go
  23. container_exec_test.go
  24. container_export.go
  25. container_export_test.go
  26. container_inspect.go
  27. container_inspect_test.go
  28. container_kill.go
  29. container_kill_test.go
  30. container_list.go
  31. container_list_test.go
  32. container_logs.go
  33. container_logs_test.go
  34. container_pause.go
  35. container_pause_test.go
  36. container_prune.go
  37. container_remove.go
  38. container_remove_test.go
  39. container_rename.go
  40. container_rename_test.go
  41. container_resize.go
  42. container_resize_test.go
  43. container_restart.go
  44. container_restart_test.go
  45. container_start.go
  46. container_start_test.go
  47. container_stats.go
  48. container_stats_test.go
  49. container_stop.go
  50. container_stop_test.go
  51. container_top.go
  52. container_top_test.go
  53. container_unpause.go
  54. container_unpause_test.go
  55. container_update.go
  56. container_update_test.go
  57. container_wait.go
  58. container_wait_test.go
  59. disk_usage.go
  60. errors.go
  61. events.go
  62. events_test.go
  63. hijack.go
  64. image_build.go
  65. image_build_test.go
  66. image_create.go
  67. image_create_test.go
  68. image_history.go
  69. image_history_test.go
  70. image_import.go
  71. image_import_test.go
  72. image_inspect.go
  73. image_inspect_test.go
  74. image_list.go
  75. image_list_test.go
  76. image_load.go
  77. image_load_test.go
  78. image_prune.go
  79. image_pull.go
  80. image_pull_test.go
  81. image_push.go
  82. image_push_test.go
  83. image_remove.go
  84. image_remove_test.go
  85. image_save.go
  86. image_save_test.go
  87. image_search.go
  88. image_search_test.go
  89. image_tag.go
  90. image_tag_test.go
  91. info.go
  92. info_test.go
  93. interface.go
  94. interface_experimental.go
  95. interface_stable.go
  96. login.go
  97. network_connect.go
  98. network_connect_test.go
  99. network_create.go
  100. network_create_test.go
  101. network_disconnect.go
  102. network_disconnect_test.go
  103. network_inspect.go
  104. network_inspect_test.go
  105. network_list.go
  106. network_list_test.go
  107. network_prune.go
  108. network_remove.go
  109. network_remove_test.go
  110. node_inspect.go
  111. node_inspect_test.go
  112. node_list.go
  113. node_list_test.go
  114. node_remove.go
  115. node_remove_test.go
  116. node_update.go
  117. node_update_test.go
  118. ping.go
  119. plugin_create.go
  120. plugin_disable.go
  121. plugin_disable_test.go
  122. plugin_enable.go
  123. plugin_enable_test.go
  124. plugin_inspect.go
  125. plugin_inspect_test.go
  126. plugin_install.go
  127. plugin_list.go
  128. plugin_list_test.go
  129. plugin_push.go
  130. plugin_push_test.go
  131. plugin_remove.go
  132. plugin_remove_test.go
  133. plugin_set.go
  134. plugin_set_test.go
  135. plugin_upgrade.go
  136. README.md
  137. request.go
  138. request_test.go
  139. secret_create.go
  140. secret_create_test.go
  141. secret_inspect.go
  142. secret_inspect_test.go
  143. secret_list.go
  144. secret_list_test.go
  145. secret_remove.go
  146. secret_remove_test.go
  147. secret_update.go
  148. secret_update_test.go
  149. service_create.go
  150. service_create_test.go
  151. service_inspect.go
  152. service_inspect_test.go
  153. service_list.go
  154. service_list_test.go
  155. service_logs.go
  156. service_logs_test.go
  157. service_remove.go
  158. service_remove_test.go
  159. service_update.go
  160. service_update_test.go
  161. swarm_get_unlock_key.go
  162. swarm_init.go
  163. swarm_init_test.go
  164. swarm_inspect.go
  165. swarm_inspect_test.go
  166. swarm_join.go
  167. swarm_join_test.go
  168. swarm_leave.go
  169. swarm_leave_test.go
  170. swarm_unlock.go
  171. swarm_update.go
  172. swarm_update_test.go
  173. task_inspect.go
  174. task_inspect_test.go
  175. task_list.go
  176. task_list_test.go
  177. transport.go
  178. utils.go
  179. version.go
  180. volume_create.go
  181. volume_create_test.go
  182. volume_inspect.go
  183. volume_inspect_test.go
  184. volume_list.go
  185. volume_list_test.go
  186. volume_prune.go
  187. volume_remove.go
  188. volume_remove_test.go
client/README.md

Go client for the Docker Engine API

The docker command uses this package to communicate with the daemon. It can also be used by your own Go applications to do anything the command-line interface does – running containers, pulling images, managing swarms, etc.

For example, to list running containers (the equivalent of docker ps):

package main

import (
	"context"
	"fmt"

	"github.com/docker/docker/api/types"
	"github.com/docker/docker/client"
)

func main() {
	cli, err := client.NewEnvClient()
	if err != nil {
		panic(err)
	}

	containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
	if err != nil {
		panic(err)
	}

	for _, container := range containers {
		fmt.Printf("%s %s\n", container.ID[:10], container.Image)
	}
}

Full documentation is available on GoDoc.