Sha256: 002bb85093c68019aa8513a5c484aa50bab049cabaa1a4fd2f93d24facf5f900
Contents?: true
Size: 693 Bytes
Versions: 12
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
12 entries across 12 versions & 1 rubygems