Sha256: 212b56ee7bb0ee0be96a2cc74efe1fd8a98d8d55fb5dee15fca9ee91481e4c10
Contents?: true
Size: 693 Bytes
Versions: 51
Compression:
Stored size: 693 Bytes
Contents
require 'docker' module DockerDatabase POSTGRES_IMAGE_NAME = 'postgres:9.6'.freeze def self.start(options) Docker::Image.create('fromImage' => POSTGRES_IMAGE_NAME) host_port = options.fetch(:port) Docker::Container.create( 'Image' => POSTGRES_IMAGE_NAME, 'name' => options.fetch(:name), 'ExposedPorts' => { '5432/tcp' => {} }, 'HostConfig' => { 'PortBindings' => { '5432/tcp' => [{ 'HostPort' => host_port }] } } ).start({}) # .tap(&:start).attach { |stream, chunk| puts "#{stream}: #{chunk}" } end def self.stop_and_remove(name) ::Docker::Container.get(name).remove(force: true) rescue nil end end
Version data entries
51 entries across 51 versions & 1 rubygems