moby-derp 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4872cf7a3115e157c1cd297c180db60444a7b46064e6192564ba9d89f3477d9
4
- data.tar.gz: 216b70b7af5e4a9e695dfcb3a668bc1fa3483ebed98ed010783977db4e20972b
3
+ metadata.gz: bdc70ac81fc8576afb34eaca6fe1faa74beeada5c176647e178f9c73cc02d96d
4
+ data.tar.gz: 369be36ae46d2ec386fe067dfa185ca3bf2526afafbb5ff6b547821f27ee1dc6
5
5
  SHA512:
6
- metadata.gz: dd9a21877adc23193d59050030abd4257d83a3de86ba5c8e722ea5fd772583f142ac4a9cc381c8c1acbc93152506dceb3fa3f63889c9fcd0a9b9d3c08dc38718
7
- data.tar.gz: 45cc46def1400c188fbf12b2d5ab0ff3e584d16ee3d9c83875dfd231b5f10bfe30813ce015533aa19a68aae479421208e470a5b98713bc1a1832692c96426741
6
+ metadata.gz: 1019db159382b95296300d4c2cecf9dadb808c796a3c5bb44d5eb2596361e962a6613cdd454865f86579a2575712ffeeb8eac55957aa8aca293c29da035dd3f5
7
+ data.tar.gz: af0a5315ea9320da3964e8ce7e76c6515529aea6fddba6a786c21002af434fc6aff84adcdda0cf556a23e826b42b5073c15b4ab6ed63d361dba3d57f90d0bc07
data/README.md CHANGED
@@ -107,6 +107,23 @@ The keys are:
107
107
  mapped by a pod, and only the pod named in the mapping can publish on the
108
108
  specified port.
109
109
 
110
+ * **`network_name`**: specify a network name to attach all pods to, if you
111
+ don't like Moby's default `bridge` network.
112
+
113
+ * **`use_host_resolv_conf`**: Moby has some... strange ideas about what
114
+ constitutes DNS records (like thinking that PTR records can only be for
115
+ rDNS). At the same time, you cannot, by purely Moby-sanctioned means,
116
+ disable the spectacularly broken DNS proxy that is inflicted on you if you
117
+ decide to use a custom network. The only feasible workaround that I have
118
+ discovered is to straight-up bind mount the host's `/etc/resolv.conf` into
119
+ every single container. If you, too, like your DNS resolution to work
120
+ properly when you use a non-default network, set this option to true.
121
+
122
+ Bear in mind, when constructing your host's `/etc/resolv.conf` file, that the
123
+ host's conception of "localhost" is different to each container's
124
+ "localhost"; so pointing to your local caching resolver using `127.0.0.1`
125
+ will not end in happiness and puppies.
126
+
110
127
  If you wish to modify the location of the `moby-derp` system-wide configuration
111
128
  file, you can do so by setting the `MOBY_DERP_SYSTEM_CONFIG_FILE` environment
112
129
  variable. Note, however, that it is a terrible idea to let ordinary users control
@@ -23,7 +23,7 @@ module MobyDerp
23
23
  "path traversal detected -- nice try, buddy"
24
24
  end
25
25
 
26
- if @source =~ %r{^(/|~)}
26
+ if @source =~ %r{^(/|~)} && @source != "/etc/resolv.conf"
27
27
  raise ConfigurationError,
28
28
  "mount sources can only be relative paths"
29
29
  end
@@ -55,6 +55,15 @@ module MobyDerp
55
55
  @common_mounts = @config.fetch("common_mounts", [])
56
56
  @expose = @config.fetch("expose", [])
57
57
  @publish = @config.fetch("publish", [])
58
+
59
+ if @system_config.use_host_resolv_conf
60
+ @common_mounts << {
61
+ "source" => "/etc/resolv.conf",
62
+ "target" => "/etc/resolv.conf",
63
+ "readonly" => true
64
+ }
65
+ end
66
+
58
67
  validate_common_mounts
59
68
  validate_expose
60
69
  validate_publish
@@ -4,16 +4,18 @@ require "safe_yaml"
4
4
 
5
5
  module MobyDerp
6
6
  class SystemConfig < ConfigFile
7
- attr_reader :mount_root, :port_whitelist, :network_name, :cpu_count, :cpu_bits
7
+ attr_reader :mount_root, :port_whitelist, :network_name, :use_host_resolv_conf,
8
+ :cpu_count, :cpu_bits
8
9
 
9
10
  def initialize(filename, moby_info, logger)
10
11
  @logger = logger
11
12
 
12
13
  super(filename)
13
14
 
14
- @mount_root = @config["mount_root"]
15
- @port_whitelist = stringify_keys(@config["port_whitelist"] || {})
16
- @network_name = @config["network_name"] || "bridge"
15
+ @mount_root = @config["mount_root"]
16
+ @port_whitelist = stringify_keys(@config["port_whitelist"] || {})
17
+ @network_name = @config["network_name"] || "bridge"
18
+ @use_host_resolv_conf = @config["use_host_resolv_conf"] || false
17
19
 
18
20
  @cpu_count = moby_info["NCPU"]
19
21
  # As far as I can tell, the only 32-bit platform Moby supports is
@@ -35,6 +37,11 @@ module MobyDerp
35
37
  "network_name must be a string"
36
38
  end
37
39
 
40
+ unless [true, false].include?(@use_host_resolv_conf)
41
+ raise ConfigurationError,
42
+ "use_host_resolv_conf must be true or false"
43
+ end
44
+
38
45
  unless File.directory?(@mount_root)
39
46
  raise ConfigurationError,
40
47
  "mount_root #{@mount_root} must exist and be a directory"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moby-derp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api