Sha256: b67cc9636d9ef06e3a0ff4f7dca7e939cbd030151b1d4167dc3d4dd79c64d7e2

Contents?: true

Size: 919 Bytes

Versions: 4

Compression:

Stored size: 919 Bytes

Contents

module Percheron
  module Container
    module Actions
      class Create

        def initialize(container)
          @container = container
        end

        def execute!
          Container::Actions::Build.new(container).execute! unless image_exists?
          $logger.debug "Creating '#{container.name}'"
          Docker::Container.create(create_opts)
        end

        private

          attr_reader :container

          def create_opts
            {
              'name'          => container.name,
              'Image'         => container.image,
              'Hostname'      => container.name,
              'Env'           => container.env,
              'ExposedPorts'  => container.exposed_ports,
              'VolumesFrom'   => container.volumes
            }
          end

          def image_exists?
            Docker::Image.exist?(container.image)
          end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
percheron-0.2.3 lib/percheron/container/actions/create.rb
percheron-0.2.2 lib/percheron/container/actions/create.rb
percheron-0.2.1 lib/percheron/container/actions/create.rb
percheron-0.2.0 lib/percheron/container/actions/create.rb