Skip to content

Instantly share code, notes, and snippets.

@tomaslin
Created November 8, 2014 00:22
Show Gist options
  • Save tomaslin/96bd8108688ea9308daa to your computer and use it in GitHub Desktop.
Save tomaslin/96bd8108688ea9308daa to your computer and use it in GitHub Desktop.
Docker calls via Spotify Docker client
@Grapes(
@Grab(group='com.spotify', module='docker-client', version='2.7.0')
)
import com.spotify.docker.client.messages.*
import com.spotify.docker.client.DefaultDockerClient
import com.spotify.docker.client.DockerClient
DockerClient docker = new DefaultDockerClient('myinstace')
def config = ContainerConfig.builder().image('busybox').cmd('env').build()
def creation = docker.createContainer(config)
println creation.id
String id = creation.id
docker.startContainer(id)
docker.waitContainer(id)
docker.killContainer(id)
println docker.logs(id, DockerClient.LogsParameter.STDOUT, DockerClient.LogsParameter.FOLLOW).readFully()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment