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