lib/hoosegow/docker.rb in hoosegow-1.2.6 vs lib/hoosegow/docker.rb in hoosegow-1.2.7
- old
+ new
@@ -77,17 +77,19 @@
#
# image - The name of the image to start the container with.
#
# Returns nothing.
def create_container(image)
+ create_options = default_container_options(image)
+
+ # Merge in additional :HostConfig options into default options
+ if @container_options.has_key?(:HostConfig)
+ create_options[:HostConfig].merge!(@container_options[:HostConfig])
+ end
+
@container = ::Docker::Container.create @container_options.merge(
- :StdinOnce => true,
- :OpenStdin => true,
- :HostConfig => {
- :Binds => volumes_for_bind
- },
- :Image => image
+ create_options
)
callback @after_create
end
# Public: Start a Docker container.
@@ -170,9 +172,22 @@
def image_exist?(name)
::Docker::Image.exist? name
end
private
+
+ # Private: Default options used to create containers
+ def default_container_options(image)
+ {
+ :StdinOnce => true,
+ :OpenStdin => true,
+ :HostConfig => {
+ :Binds => volumes_for_bind
+ },
+ :Image => image
+ }
+ end
+
# Private: Set the docker URL, if related options are present.
def set_docker_url!(options)
if url = docker_url(options)
::Docker.url = url
end