{"id":26776867,"url":"https://github.com/mdelapenya/docker-sdk-go","last_synced_at":"2025-08-17T01:09:56.616Z","repository":{"id":284540945,"uuid":"955269110","full_name":"docker/go-sdk","owner":"docker","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-28T11:51:29.000Z","size":20997,"stargazers_count":39,"open_issues_count":7,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-08T09:48:46.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/docker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-26T11:31:06.000Z","updated_at":"2025-08-04T08:13:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f7030cd-e880-4513-9075-d99c11ab2015","html_url":"https://github.com/docker/go-sdk","commit_stats":null,"previous_names":["mdelapenya/docker-sdk-go","docker/go-sdk"],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/docker/go-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fgo-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fgo-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fgo-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fgo-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/docker","download_url":"https://codeload.github.com/docker/go-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fgo-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270793483,"owners_count":24646597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-29T04:36:58.369Z","updated_at":"2025-08-17T01:09:56.601Z","avatar_url":"https://github.com/docker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚠️ Disclaimer\n\n**This repository is Work in Progress (WIP)**. We are actively developing and improving this SDK. While the current functionality is stable and continuously tested in the CI, the API may change as we continue to enhance and refine the codebase until we reach a `v1.0.0` release. We recommend:\n\n- Using specific version tags in your dependencies.\n- Reviewing the changelog before upgrading.\n- Testing thoroughly in your environment.\n- Reporting any issues you encounter.\n\n# Docker SDK for Go\n\nA lightweight, modular SDK for interacting with Docker configuration and context data in Go.\n\nThis project is designed to be:\n- **Extensible**: Built with composability in mind to support additional Docker-related features.\n- **Lightweight**: No unnecessary dependencies; only what's needed to manage Docker configurations.\n- **Go-native**: Idiomatic Go modules for clean integration in CLI tools and backend services.\n\n## Features\n\n- Initialize a Docker client, using the current Docker context to resolve the Docker host and socket\n- Parse and load Docker CLI config (`~/.docker/config.json`)\n- Handle credential helpers\n- Read and manage Docker contexts\n- Pull images from a remote registry, retrying on non-permanent errors\n\n## Installation\n\n```bash\ngo get github.com/docker/go-sdk/client\ngo get github.com/docker/go-sdk/config\ngo get github.com/docker/go-sdk/container\ngo get github.com/docker/go-sdk/context\ngo get github.com/docker/go-sdk/image\ngo get github.com/docker/go-sdk/network\ngo get github.com/docker/go-sdk/volume\n```\n\n## Usage\n\n### client\n\nUsing the default client:\n\n```go\ncli := client.DefaultClient\n```\n\nCreating a new client, with optional configuration:\n\n```go\ncli, err := client.New(context.Background(), client.WithDockerContext(\"my-docker-context\"))\nif err != nil {\n    log.Fatalf(\"failed to create docker client: %v\", err)\n}\n\n// Close the docker client when done\ndefer cli.Close()\n```\n\nPlease refer to the [client](./client/README.md) package for more information.\n\n### config\n\n```go\ncfg, err := config.Load()\nif err != nil {\n    log.Fatalf(\"failed to load config: %v\", err)\n}\n\nauth, ok := cfg.AuthConfigs[\"https://index.docker.io/v1/\"]\nif ok {\n    fmt.Println(\"Username:\", auth.Username)\n}\n```\n\n### container\n\n```go\nctr, err := container.Run(context.Background(),\n    container.WithImage(\"nginx:alpine\"),\n    container.WithImagePlatform(\"linux/amd64\"),\n    container.WithAlwaysPull(),\n    container.WithExposedPorts(\"80/tcp\"),\n    container.WithWaitStrategy(wait.ForListeningPort(\"80/tcp\")),\n)\nif err != nil {\n    log.Fatalf(\"failed to run container: %v\", err)\n}\n\ncontainer.Terminate(ctr)\n```\n\n### context\n\n```go\ncurrent, err := context.Current()\nif err != nil {\n    log.Fatalf(\"failed to get current docker context: %v\", err)\n}\n\nfmt.Printf(\"current docker context: %s\", current)\n\ndockerHost, err := context.CurrentDockerHost()\nif err != nil {\n    log.Fatalf(\"failed to get current docker host: %v\", err)\n}\nfmt.Printf(\"current docker host: %s\", dockerHost)\n```\n\n### image\n\n```go\nimport (\n\t\"context\"\n\n    apiimage \"github.com/docker/docker/api/types/image\"\n\t\"github.com/docker/go-sdk/client\"\n\t\"github.com/docker/go-sdk/image\"\n)\n\nctx := context.Background()\ndockerClient, err := client.New(ctx)\nif err != nil {\n    log.Fatalf(\"failed to create docker client: %v\", err)\n}\ndefer dockerClient.Close()\n\nerr = image.Pull(ctx,\n    \"nginx:alpine\",\n    image.WithPullClient(dockerClient),\n    image.WithPullOptions(apiimage.PullOptions{}),\n)\nif err != nil {\n    log.Fatalf(\"failed to pull image: %v\", err)\n}\n\n```\n\n### network\n\n```go\nnw, err := network.New(ctx)\nif err != nil {\n    log.Fatalf(\"failed to create network: %v\", err)\n}\n\nresp, err := nw.Inspect(ctx)\nif err != nil {\n    log.Fatalf(\"failed to inspect network: %v\", err)\n}\n\nerr = nw.Terminate(ctx)\nif err != nil {\n    log.Fatalf(\"failed to terminate network: %v\", err)\n}\n```\n\n### volume\n\n```go\nv, err := volume.New(ctx)\nif err != nil {\n    log.Fatalf(\"failed to create volume: %v\", err)\n}\n\nvol, err := volume.FindByID(ctx, v.ID())\nif err != nil {\n    log.Println(err)\n    return\n}\n\nerr = v.Terminate(ctx)\nif err != nil {\n    log.Fatalf(\"failed to terminate volume: %v\", err)\n}\n```\n\nMore usage examples are coming soon!\n\n## Contributing\n\nWe welcome contributions! Please read the [CONTRIBUTING](./CONTRIBUTING.md) file and open issues or submit pull requests once you're ready. Make sure your changes are well-tested and documented.\n\n## Licensing\n\nThis project is licensed under the [Apache License 2.0](./LICENSE).\n\nIt includes portions of code derived from other open source projects which are licensed under the MIT License. Their original licenses are preserved [here](./third_party), and attribution is provided in the [NOTICE](./NOTICE) file.\n\nModifications have been made to this code as part of its integration into this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdelapenya%2Fdocker-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdelapenya%2Fdocker-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdelapenya%2Fdocker-sdk-go/lists"}