Sha256: 97b7b359ffbba12c67bde8ceb256956ada319f7dda93ebfa2eab25dec318d501

Contents?: true

Size: 906 Bytes

Versions: 9

Compression:

Stored size: 906 Bytes

Contents

module Percheron
  module Container
    module Actions
      class Start

        def initialize(container)
          @container = container
        end

        def execute!
          if container.exists?
            $logger.debug "Starting '#{container.name}'"
            container.docker_container.start!(start_opts)
          else
            raise Errors::ContainerDoesNotExist.new
          end
        end

        private

          attr_reader :container

          def start_opts
            opts = container.ports.inject({}) do |all, p|
              destination, source = p.split(':')
              all[source] = [ { 'HostPort' => destination } ]
              all
            end

            {
              'PortBindings'  => opts,
              'Links'         => container.links,
              'Binds'         => container.volumes
            }
          end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
percheron-0.4.0 lib/percheron/container/actions/start.rb
percheron-0.3.2 lib/percheron/container/actions/start.rb
percheron-0.3.1 lib/percheron/container/actions/start.rb
percheron-0.3.0 lib/percheron/container/actions/start.rb
percheron-0.2.4 lib/percheron/container/actions/start.rb
percheron-0.2.3 lib/percheron/container/actions/start.rb
percheron-0.2.2 lib/percheron/container/actions/start.rb
percheron-0.2.1 lib/percheron/container/actions/start.rb
percheron-0.2.0 lib/percheron/container/actions/start.rb