tree: c959d0829f4e3568183250bf4053de3313a2c789 [path history] [tgz]
  1. internal/
  2. pkg/
  3. releases/
  4. testdata/
  5. auth.go
  6. build_cancel.go
  7. build_prune.go
  8. checkpoint.go
  9. checkpoint_create.go
  10. checkpoint_create_test.go
  11. checkpoint_delete.go
  12. checkpoint_delete_test.go
  13. checkpoint_list.go
  14. checkpoint_list_test.go
  15. client.go
  16. client_interfaces.go
  17. client_mock_test.go
  18. client_test.go
  19. client_unix.go
  20. client_windows.go
  21. config_create.go
  22. config_create_test.go
  23. config_inspect.go
  24. config_inspect_test.go
  25. config_list.go
  26. config_list_test.go
  27. config_remove.go
  28. config_remove_test.go
  29. config_update.go
  30. config_update_test.go
  31. container_attach.go
  32. container_commit.go
  33. container_commit_test.go
  34. container_copy.go
  35. container_copy_test.go
  36. container_create.go
  37. container_create_test.go
  38. container_diff.go
  39. container_diff_test.go
  40. container_exec.go
  41. container_exec_test.go
  42. container_export.go
  43. container_export_test.go
  44. container_inspect.go
  45. container_inspect_test.go
  46. container_kill.go
  47. container_kill_test.go
  48. container_list.go
  49. container_list_test.go
  50. container_logs.go
  51. container_logs_test.go
  52. container_pause.go
  53. container_pause_test.go
  54. container_prune.go
  55. container_prune_test.go
  56. container_remove.go
  57. container_remove_test.go
  58. container_rename.go
  59. container_rename_test.go
  60. container_resize.go
  61. container_resize_test.go
  62. container_restart.go
  63. container_restart_test.go
  64. container_start.go
  65. container_start_test.go
  66. container_stats.go
  67. container_stats_test.go
  68. container_stop.go
  69. container_stop_test.go
  70. container_top.go
  71. container_top_test.go
  72. container_unpause.go
  73. container_unpause_test.go
  74. container_update.go
  75. container_update_test.go
  76. container_wait.go
  77. container_wait_test.go
  78. distribution_inspect.go
  79. distribution_inspect_test.go
  80. envvars.go
  81. errors.go
  82. go.mod
  83. go.sum
  84. hijack.go
  85. hijack_test.go
  86. image_build.go
  87. image_build_opts.go
  88. image_build_test.go
  89. image_create.go
  90. image_create_opts.go
  91. image_create_test.go
  92. image_history.go
  93. image_history_opts.go
  94. image_history_test.go
  95. image_import.go
  96. image_import_opts.go
  97. image_import_test.go
  98. image_inspect.go
  99. image_inspect_opts.go
  100. image_inspect_test.go
  101. image_list.go
  102. image_list_opts.go
  103. image_list_test.go
  104. image_load.go
  105. image_load_opts.go
  106. image_load_test.go
  107. image_prune.go
  108. image_prune_test.go
  109. image_pull.go
  110. image_pull_opts.go
  111. image_pull_test.go
  112. image_push.go
  113. image_push_opts.go
  114. image_push_test.go
  115. image_remove.go
  116. image_remove_opts.go
  117. image_remove_test.go
  118. image_save.go
  119. image_save_opts.go
  120. image_save_test.go
  121. image_search.go
  122. image_search_opts.go
  123. image_search_test.go
  124. image_tag.go
  125. image_tag_test.go
  126. login.go
  127. network_connect.go
  128. network_connect_opts.go
  129. network_connect_test.go
  130. network_create.go
  131. network_create_opts.go
  132. network_create_test.go
  133. network_disconnect.go
  134. network_disconnect_opts.go
  135. network_disconnect_test.go
  136. network_inspect.go
  137. network_inspect_opts.go
  138. network_inspect_test.go
  139. network_list.go
  140. network_list_opts.go
  141. network_list_test.go
  142. network_prune.go
  143. network_prune_test.go
  144. network_remove.go
  145. network_remove_test.go
  146. node_inspect.go
  147. node_inspect_test.go
  148. node_list.go
  149. node_list_test.go
  150. node_remove.go
  151. node_remove_test.go
  152. node_update.go
  153. node_update_test.go
  154. options.go
  155. options_test.go
  156. ping.go
  157. ping_test.go
  158. plugin_create.go
  159. plugin_disable.go
  160. plugin_disable_test.go
  161. plugin_enable.go
  162. plugin_enable_test.go
  163. plugin_inspect.go
  164. plugin_inspect_test.go
  165. plugin_install.go
  166. plugin_list.go
  167. plugin_list_test.go
  168. plugin_push.go
  169. plugin_push_test.go
  170. plugin_remove.go
  171. plugin_remove_test.go
  172. plugin_set.go
  173. plugin_set_test.go
  174. plugin_upgrade.go
  175. README.md
  176. request.go
  177. request_test.go
  178. secret_create.go
  179. secret_create_test.go
  180. secret_inspect.go
  181. secret_inspect_test.go
  182. secret_list.go
  183. secret_list_opts.go
  184. secret_list_test.go
  185. secret_remove.go
  186. secret_remove_test.go
  187. secret_update.go
  188. secret_update_test.go
  189. service_create.go
  190. service_create_test.go
  191. service_inspect.go
  192. service_inspect_test.go
  193. service_list.go
  194. service_list_test.go
  195. service_logs.go
  196. service_logs_test.go
  197. service_remove.go
  198. service_remove_test.go
  199. service_update.go
  200. service_update_test.go
  201. swarm_config_list_options.go
  202. swarm_get_unlock_key.go
  203. swarm_get_unlock_key_test.go
  204. swarm_init.go
  205. swarm_init_test.go
  206. swarm_inspect.go
  207. swarm_inspect_test.go
  208. swarm_join.go
  209. swarm_join_test.go
  210. swarm_leave.go
  211. swarm_leave_test.go
  212. swarm_node_list_opts.go
  213. swarm_node_remove_opts.go
  214. swarm_service_create_opts.go
  215. swarm_service_inspect_opts.go
  216. swarm_service_list_opts.go
  217. swarm_service_update_opts.go
  218. swarm_task_list_opts.go
  219. swarm_unlock.go
  220. swarm_unlock_test.go
  221. swarm_update.go
  222. swarm_update_flags.go
  223. swarm_update_test.go
  224. system_disk_usage.go
  225. system_disk_usage_opts.go
  226. system_disk_usage_test.go
  227. system_events.go
  228. system_events_test.go
  229. system_info.go
  230. system_info_test.go
  231. task_inspect.go
  232. task_inspect_test.go
  233. task_list.go
  234. task_list_test.go
  235. task_logs.go
  236. utils.go
  237. utils_test.go
  238. version.go
  239. volume_create.go
  240. volume_create_test.go
  241. volume_inspect.go
  242. volume_inspect_test.go
  243. volume_list.go
  244. volume_list_opts.go
  245. volume_list_test.go
  246. volume_prune.go
  247. volume_remove.go
  248. volume_remove_test.go
  249. volume_update.go
  250. volume_update_test.go
client/README.md

Go client for the Docker Engine API

PkgGoDev GitHub License Go Report Card OpenSSF Scorecard OpenSSF Best Practices

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 or pushing images, etc.

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

package main

import (
	"context"
	"fmt"

	"github.com/moby/moby/client"
)

func main() {
	apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
	if err != nil {
		panic(err)
	}
	defer apiClient.Close()

	containers, err := apiClient.ContainerList(context.Background(), client.ContainerListOptions{All: true})
	if err != nil {
		panic(err)
	}

	for _, ctr := range containers {
		fmt.Printf("%s %s (status: %s)\n", ctr.ID, ctr.Image, ctr.Status)
	}
}

Full documentation is available on pkg.go.dev.