{"id":13416519,"url":"https://github.com/spotify/docker-client","last_synced_at":"2025-09-28T19:31:28.616Z","repository":{"id":17679663,"uuid":"20484506","full_name":"spotify/docker-client","owner":"spotify","description":"INACTIVE: A simple docker client for the JVM","archived":true,"fork":false,"pushed_at":"2022-01-24T12:57:44.000Z","size":3609,"stargazers_count":1434,"open_issues_count":66,"forks_count":549,"subscribers_count":71,"default_branch":"master","last_synced_at":"2025-01-16T04:11:00.559Z","etag":null,"topics":["containers","docker","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spotify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-04T13:22:10.000Z","updated_at":"2024-12-31T09:02:44.000Z","dependencies_parsed_at":"2022-09-03T08:20:36.048Z","dependency_job_id":null,"html_url":"https://github.com/spotify/docker-client","commit_stats":null,"previous_names":[],"tags_count":166,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdocker-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdocker-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdocker-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdocker-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spotify","download_url":"https://codeload.github.com/spotify/docker-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234555772,"owners_count":18851841,"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","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":["containers","docker","java"],"created_at":"2024-07-30T21:01:00.093Z","updated_at":"2025-09-28T19:31:23.169Z","avatar_url":"https://github.com/spotify.png","language":"Java","readme":"# Docker Client\n\n[![Build Status](https://travis-ci.com/spotify/docker-client.svg?branch=master)](https://travis-ci.com/spotify/docker-client)\n[![codecov](https://codecov.io/github/spotify/docker-client/coverage.svg?branch=master)](https://codecov.io/github/spotify/docker-client?branch=master)\n[![Maven Central](https://img.shields.io/maven-central/v/com.spotify/docker-client.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.spotify%22%20docker-client)\n[![License](https://img.shields.io/github/license/spotify/docker-client.svg)](LICENSE)\n\n## Status: mature\n\n**Spotify no longer uses recent versions of this project internally. The\nversion of docker-client we're using is whatever helios has in its\n[pom.xml][helios-pom]. At this point, we're not developing or accepting new\nfeatures or even fixing non-critical bugs. Feel free to fork this repo though.**\n\n[helios-pom]: https://github.com/spotify/helios/blob/master/pom.xml\n\nThis is a [Docker](https://github.com/docker/docker) client written in Java.\nIt is used in many critical production systems at Spotify.\n\n* [Version compatibility](#version-compatibility)\n* [Download](#download)\n* [Usage Example](#usage-example)\n* [Getting Started](#getting-started)\n* [Prerequisites](#prerequisites)\n* [Testing](#testing)\n* [Releasing](#releasing)\n* [A Note on Shading](#a-note-on-shading)\n* [Code of Conduct](#code-of-conduct)\n* [User Manual](https://github.com/spotify/docker-client/blob/master/docs/user_manual.md)\n\n## Version compatibility\ndocker-client is built and tested against the six most recent minor releases of Docker.\nRight now these are 17.03.1~ce - 17.12.1~ce (specifically the ones [here][1]).\nWe upload the artifact tested on Docker 17.12.1~ce.\nSee [Docker docs on the mapping between Docker version and API version][3].\n\n## Download\n\nDownload the latest JAR or grab [via Maven][maven-search].\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.spotify\u003c/groupId\u003e\n  \u003cartifactId\u003edocker-client\u003c/artifactId\u003e\n  \u003cversion\u003eLATEST-VERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n## Usage Example\n\n```java\n// Create a client based on DOCKER_HOST and DOCKER_CERT_PATH env vars\nfinal DockerClient docker = DefaultDockerClient.fromEnv().build();\n\n// Pull an image\ndocker.pull(\"busybox\");\n\n// Bind container ports to host ports\nfinal String[] ports = {\"80\", \"22\"};\nfinal Map\u003cString, List\u003cPortBinding\u003e\u003e portBindings = new HashMap\u003c\u003e();\nfor (String port : ports) {\n    List\u003cPortBinding\u003e hostPorts = new ArrayList\u003c\u003e();\n    hostPorts.add(PortBinding.of(\"0.0.0.0\", port));\n    portBindings.put(port, hostPorts);\n}\n\n// Bind container port 443 to an automatically allocated available host port.\nList\u003cPortBinding\u003e randomPort = new ArrayList\u003c\u003e();\nrandomPort.add(PortBinding.randomPort(\"0.0.0.0\"));\nportBindings.put(\"443\", randomPort);\n\nfinal HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).build();\n\n// Create container with exposed ports\nfinal ContainerConfig containerConfig = ContainerConfig.builder()\n    .hostConfig(hostConfig)\n    .image(\"busybox\").exposedPorts(ports)\n    .cmd(\"sh\", \"-c\", \"while :; do sleep 1; done\")\n    .build();\n\nfinal ContainerCreation creation = docker.createContainer(containerConfig);\nfinal String id = creation.id();\n\n// Inspect container\nfinal ContainerInfo info = docker.inspectContainer(id);\n\n// Start container\ndocker.startContainer(id);\n\n// Exec command inside running container with attached STDOUT and STDERR\nfinal String[] command = {\"sh\", \"-c\", \"ls\"};\nfinal ExecCreation execCreation = docker.execCreate(\n    id, command, DockerClient.ExecCreateParam.attachStdout(),\n    DockerClient.ExecCreateParam.attachStderr());\nfinal LogStream output = docker.execStart(execCreation.id());\nfinal String execOutput = output.readFully();\n\n// Kill container\ndocker.killContainer(id);\n\n// Remove container\ndocker.removeContainer(id);\n\n// Close the docker client\ndocker.close();\n```\n\n## Getting Started\n\nIf you're looking for how to use docker-client, see the [User Manual][2].\nIf you're looking for how to build and develop it, keep reading.\n\n## Prerequisites\n\ndocker-client should be buildable on any platform with Docker 1.6+, JDK8+, and a recent version of\nMaven 3.\n\n### A note on using Docker for Mac\n\nIf you are using Docker for Mac and `DefaultDockerClient.fromEnv()`, it might not be clear\nwhat value to use for the `DOCKER_HOST` environment variable. The value you should use is\n`DOCKER_HOST=unix:///var/run/docker.sock`, at least as of version 1.11.1-beta11.\n\nAs of version 4.0.8 of docker-client, `DefaultDockerClient.fromEnv()` uses\n`unix:///var/run/docker.sock` on OS X by default.\n\n## Testing\n\nIf you're running a recent version of docker (\u003e= 1.12), which contains native swarm support, please\nensure that you run `docker swarm init` to initialize the docker swarm.\n\nMake sure Docker daemon is running and that you can do `docker ps`.\n\nYou can run tests on their own with `mvn test`. Note that the tests start and stop a large number of\ncontainers, so the list of containers you see with `docker ps -a` will start to get pretty long\nafter many test runs. You may find it helpful to occasionally issue `docker rm $(docker ps -aq)`.\n\n## Releasing\n\nCommits to the master branch will trigger our continuous integration agent to build the jar and\nrelease by uploading to Sonatype. If you are a project maintainer with the necessary credentials,\nyou can also build and release locally by running the below.\n\n```sh\nmvn clean [-DskipTests -Darguments=-DskipTests] -Dgpg.keyname=\u003ckey ID used for signing artifacts\u003e release:prepare release:perform\n```\n\n## A note on shading\n\nPlease note that in releases 2.7.6 and earlier, the default artifact was the shaded version.\nWhen upgrading to version 2.7.7, you will need to include the shaded classifier if you relied on\nthe shaded dependencies in the docker-client jar.\n\nStandard:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.spotify\u003c/groupId\u003e\n  \u003cartifactId\u003edocker-client\u003c/artifactId\u003e\n  \u003cversion\u003e3.5.12\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nShaded:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.spotify\u003c/groupId\u003e\n  \u003cartifactId\u003edocker-client\u003c/artifactId\u003e\n  \u003cclassifier\u003eshaded\u003c/classifier\u003e\n  \u003cversion\u003e3.5.12\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n**This is particularly important if you use Jersey 1.x in your project. To avoid conflicts with\ndocker-client and Jersey 2.x, you will need to explicitly specify the shaded version above.**\n\n\n  [1]: https://travis-ci.org/spotify/docker-client\n  [2]: docs/user_manual.md\n  [3]: https://docs.docker.com/engine/api/v1.27/#section/Versioning\n\n\n## Code of conduct\n\nThis project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are\nexpected to honor this code.\n\n  [code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md\n  [maven-search]: https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.spotify%22%20docker-client\n","funding_links":[],"categories":["Development with Docker","Java","java"],"sub_categories":["API Client"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2Fdocker-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspotify%2Fdocker-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2Fdocker-client/lists"}