0.0
No commit activity in last 3 years
No release in over 3 years
This gem is intended to aid in using Docker images and containers, specifically with regards to integration testing in RSpec.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.21.4, ~> 1.0
 Project Readme

Longshoreman

Abstracting the Docker API for easier use with RSpec

See https://github.com/swipely/docker-api and https://rubygems.org/gems/docker-api for more information about the Docker API gem.

What is Longshoreman?

An instance of Longshoreman contains both an image object and a container object which are completely independent of each other. The image object is primarily useful for building an image from a Dockerfile, and then creating a container from that image.

Usage

Environment Variables

If you set the DOCKER_URL environment variable before launching your tests (or script or application) the Docker API will automatically pick up the necessary information.

Methods

Create an instance with an empty container and image (the default):

l = Longshoreman.new


Create a container from a known image in `repository:tag` format and start it in
one step:

>```
l = Longshoreman.new('ubuntu:latest', 'my_container_name')

Clean up the container and/or image associated with your Longshoreman instance:

l.cleanup


Interact with the container:

>```
l.container.METHOD

Container methods include all, cleanup, create, get, id, remove, rport, start and stop.

rport is used to return the randomized port mapped by Docker:

def rport(exposed_port, protocol='tcp')

l.container.rport(10051) => 32791


Interact with the image:

>```
l.image.METHOD

Image methods include build, remove, get, exist?, and id.

You also have full access to the Docker API gem's functionality for both the image and container instances by way of .raw:

l.container.raw.json {...json output here...}


>```
l.image.raw.json
{...json output here...}