All Projects → spotify → Docker Client

spotify / Docker Client

Licence: apache-2.0
INACTIVE: A simple docker client for the JVM

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Docker Client

Docker Series
Docker Series about containerizing ASP.NET Core app with MySQL..
Stars: ✭ 88 (-93.62%)
Mutual labels:  containers
Csi Test
CSI test frameworks
Stars: ✭ 90 (-93.48%)
Mutual labels:  containers
Singularity Cri
The Singularity implementation of the Kubernetes Container Runtime Interface
Stars: ✭ 97 (-92.97%)
Mutual labels:  containers
Docker For All
Docker applied in development, devops, testing, product management etc.
Stars: ✭ 88 (-93.62%)
Mutual labels:  containers
Falco Security Workshop
Container Security Workshop covering using Falco on Kubernetes.
Stars: ✭ 91 (-93.41%)
Mutual labels:  containers
Minicps
MiniCPS: a framework for Cyber-Physical Systems real-time simulation, built on top of mininet
Stars: ✭ 92 (-93.33%)
Mutual labels:  containers
Otomi Core
Otomi Container Platform, a suite of integrated best of breed open source tools combined with automation & self service, all wrapped together and made available as an enterprise ready and single deployable solution
Stars: ✭ 84 (-93.91%)
Mutual labels:  containers
Go Digest
Common digest package used across the container ecosystem
Stars: ✭ 99 (-92.83%)
Mutual labels:  containers
Bitnami Docker Airflow
Bitnami Docker Image for Apache Airflow
Stars: ✭ 89 (-93.55%)
Mutual labels:  containers
Faasd
A lightweight & portable faas engine
Stars: ✭ 1,330 (-3.62%)
Mutual labels:  containers
Copilot Cli
The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on Amazon ECS and AWS Fargate.
Stars: ✭ 1,285 (-6.88%)
Mutual labels:  containers
Footloose
Container Machines - Containers that look like Virtual Machines
Stars: ✭ 1,289 (-6.59%)
Mutual labels:  containers
Docker
Directus Docker — The Official Docker Container for the Directus Suite
Stars: ✭ 93 (-93.26%)
Mutual labels:  containers
Gameon Java Microservices On Kubernetes
This code demonstrates deployment of a Microservices based application Game On! on to Kubernetes cluster. Game On! is a throwback text-based adventure built to help you explore microservice architectures and related concepts.
Stars: ✭ 88 (-93.62%)
Mutual labels:  containers
Riff Tutorial
How-to guide for testing the riff FaaS platform and Istio on Google Kubernetes Engine.
Stars: ✭ 99 (-92.83%)
Mutual labels:  containers
Ubiquity
Ubiquity
Stars: ✭ 86 (-93.77%)
Mutual labels:  containers
Gke Bazel Demo
Building applications with bazel and deploying them on to GKE. This demo contains a java-spring-boot rest service and an angular front-end. Both containers are deployed on GKE.
Stars: ✭ 92 (-93.33%)
Mutual labels:  containers
Dotnettency
Mutlitenancy for dotnet applications
Stars: ✭ 100 (-92.75%)
Mutual labels:  containers
Screen Recorder Ffmpeg Cpp
*Multimedia project* A screen recording application to capture your desktop and store in a video format. Click here to watch the demo
Stars: ✭ 98 (-92.9%)
Mutual labels:  containers
Bitnami Docker Testlink
Bitnami Docker Image for TestLink
Stars: ✭ 95 (-93.12%)
Mutual labels:  containers

Docker Client

Build Status codecov Maven Central License

Status: mature

Spotify no longer uses recent versions of this project internally. The version of docker-client we're using is whatever helios has in its pom.xml. At this point, we're not developing or accepting new features or even fixing non-critical bugs. Feel free to fork this repo though.

This is a Docker client written in Java. It is used in many critical production systems at Spotify.

Version compatibility

docker-client is built and tested against the six most recent minor releases of Docker. Right now these are 17.03.1ce - 17.12.1ce (specifically the ones here). We upload the artifact tested on Docker 17.12.1~ce. See Docker docs on the mapping between Docker version and API version.

Download

Download the latest JAR or grab via Maven.

<dependency>
  <groupId>com.spotify</groupId>
  <artifactId>docker-client</artifactId>
  <version>LATEST-VERSION</version>
</dependency>

Usage Example

// Create a client based on DOCKER_HOST and DOCKER_CERT_PATH env vars
final DockerClient docker = DefaultDockerClient.fromEnv().build();

// Pull an image
docker.pull("busybox");

// Bind container ports to host ports
final String[] ports = {"80", "22"};
final Map<String, List<PortBinding>> portBindings = new HashMap<>();
for (String port : ports) {
    List<PortBinding> hostPorts = new ArrayList<>();
    hostPorts.add(PortBinding.of("0.0.0.0", port));
    portBindings.put(port, hostPorts);
}

// Bind container port 443 to an automatically allocated available host port.
List<PortBinding> randomPort = new ArrayList<>();
randomPort.add(PortBinding.randomPort("0.0.0.0"));
portBindings.put("443", randomPort);

final HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).build();

// Create container with exposed ports
final ContainerConfig containerConfig = ContainerConfig.builder()
    .hostConfig(hostConfig)
    .image("busybox").exposedPorts(ports)
    .cmd("sh", "-c", "while :; do sleep 1; done")
    .build();

final ContainerCreation creation = docker.createContainer(containerConfig);
final String id = creation.id();

// Inspect container
final ContainerInfo info = docker.inspectContainer(id);

// Start container
docker.startContainer(id);

// Exec command inside running container with attached STDOUT and STDERR
final String[] command = {"sh", "-c", "ls"};
final ExecCreation execCreation = docker.execCreate(
    id, command, DockerClient.ExecCreateParam.attachStdout(),
    DockerClient.ExecCreateParam.attachStderr());
final LogStream output = docker.execStart(execCreation.id());
final String execOutput = output.readFully();

// Kill container
docker.killContainer(id);

// Remove container
docker.removeContainer(id);

// Close the docker client
docker.close();

Getting Started

If you're looking for how to use docker-client, see the User Manual. If you're looking for how to build and develop it, keep reading.

Prerequisites

docker-client should be buildable on any platform with Docker 1.6+, JDK8+, and a recent version of Maven 3.

A note on using Docker for Mac

If you are using Docker for Mac and DefaultDockerClient.fromEnv(), it might not be clear what value to use for the DOCKER_HOST environment variable. The value you should use is DOCKER_HOST=unix:///var/run/docker.sock, at least as of version 1.11.1-beta11.

As of version 4.0.8 of docker-client, DefaultDockerClient.fromEnv() uses unix:///var/run/docker.sock on OS X by default.

Testing

If you're running a recent version of docker (>= 1.12), which contains native swarm support, please ensure that you run docker swarm init to initialize the docker swarm.

Make sure Docker daemon is running and that you can do docker ps.

You can run tests on their own with mvn test. Note that the tests start and stop a large number of containers, so the list of containers you see with docker ps -a will start to get pretty long after many test runs. You may find it helpful to occasionally issue docker rm $(docker ps -aq).

Releasing

Commits to the master branch will trigger our continuous integration agent to build the jar and release by uploading to Sonatype. If you are a project maintainer with the necessary credentials, you can also build and release locally by running the below.

mvn clean [-DskipTests -Darguments=-DskipTests] -Dgpg.keyname=<key ID used for signing artifacts> release:prepare release:perform

A note on shading

Please note that in releases 2.7.6 and earlier, the default artifact was the shaded version. When upgrading to version 2.7.7, you will need to include the shaded classifier if you relied on the shaded dependencies in the docker-client jar.

Standard:

<dependency>
  <groupId>com.spotify</groupId>
  <artifactId>docker-client</artifactId>
  <version>3.5.12</version>
</dependency>

Shaded:

<dependency>
  <groupId>com.spotify</groupId>
  <artifactId>docker-client</artifactId>
  <classifier>shaded</classifier>
  <version>3.5.12</version>
</dependency>

This is particularly important if you use Jersey 1.x in your project. To avoid conflicts with docker-client and Jersey 2.x, you will need to explicitly specify the shaded version above.

Code of conduct

This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].