A port of Docker client written in groovy meant to make easy to create JUnit tests with Docker.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.crypto
config/codenarc
doc
gradle/wrapper
src
.gitignore
.travis.yml
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

docker-komposer

Build Status

This project aims to make easy to use docker-compose feature inside Java/Groovy projects.

It comes with an JUnit rule implementation to allow the container creation on java testing.

How to Use:

Import the project dependecy from maven on your specific build tool

Create the Rule object:

    @ClassRule public static KomposerRule container = new KomposerRule("docker-compose-test.yml", "docker.properties", false); 
    container.getContainers().get("serviceName").getContainerInfo(); // returns the container inspect from docker

Other option to start your compose:

    @Shared def options = [
            compose:        'src/test/resources/compose/compose-cobra.yml',
            dockerCfg:      'docker.properties',
            pull:           DOCKER_HUB_PULL_ENABLE, // only pull images when not exists on docker server
            privateNetwork: CREATE_PRIVATE_NETWORK, // bidirectional communication
            forcePull:      DOCKER_HUB_FORCE_PULL_ENABLE  // always pull images
    ]
    
    @Before
	public void setUp() throws Exception {
        rule = new KomposerRule(options)
        rule.before()
    }
    
    @After
    public void tearDown() throws Exception {
        rule.after()
    }

The docker.properties file is optional, and can contain:

host= docker host
cert.path= if is a secure connection
# in case of using docker hub to pull private images
hub.user= 
hub.pass=
hub.email=

If property file is informed, docker client will try to connect using environment variables.