diff --git a/plugins/providers/docker/config.rb b/plugins/providers/docker/config.rb index ca3d5a2ae..64d1ae620 100644 --- a/plugins/providers/docker/config.rb +++ b/plugins/providers/docker/config.rb @@ -29,7 +29,7 @@ module VagrantPlugins # file. This can be used for adding networks or volumes. # # @return [Hash] - attr_reader :compose_configuration + attr_accessor :compose_configuration # An optional file name of a Dockerfile to be used when building # the image. This requires Docker >1.5.0. @@ -252,6 +252,11 @@ module VagrantPlugins @vagrant_machine = @vagrant_machine.to_sym if @vagrant_machine @expose.uniq! + + if @compose_configuration.is_a?(Hash) + # Ensures configuration is using basic types + @compose_configuration = JSON.parse(@compose_configuration.to_json) + end end def validate(machine) @@ -272,6 +277,10 @@ module VagrantPlugins end end + if !@compose_configuration.is_a?(Hash) + errors << I18n.t("docker_provider.errors.config.compose_configuration_hash") + end + if !@create_args.is_a?(Array) errors << I18n.t("docker_provider.errors.config.create_args_array") end diff --git a/plugins/providers/docker/driver/compose.rb b/plugins/providers/docker/driver/compose.rb index bfe7a9d38..5ad3c8cd9 100644 --- a/plugins/providers/docker/driver/compose.rb +++ b/plugins/providers/docker/driver/compose.rb @@ -91,7 +91,7 @@ module VagrantPlugins update_composition(:apply) do |composition| services = composition["services"] ||= {} services[name] ||= {} - services[name].merge( + services[name].merge!( "image" => image, "environment" => env, "expose" => expose,