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

package main

import (
	"context"
	"fmt"

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

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

	containers, err := apiClient.ContainerList(context.Background(), container.ListOptions{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.