Skip to content

Commit

Permalink
Add Docker compatibility for --dns-option to --dns-opt
Browse files Browse the repository at this point in the history
Fixes one of the issues found in containers#14917
Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Aug 15, 2022
1 parent 4136496 commit b9c094a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/podman/common/netflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func DefineNetFlags(cmd *cobra.Command) {
"Set custom DNS options",
)
_ = cmd.RegisterFlagCompletionFunc(dnsOptFlagName, completion.AutocompleteNone)
netFlags.StringSlice(
"dns-option", containerConfig.DNSOptions(),
"Docker compatibility option== --dns-opt",
)
_ = netFlags.MarkHidden("dns-option")

dnsSearchFlagName := "dns-search"
netFlags.StringSlice(
Expand Down Expand Up @@ -146,6 +151,14 @@ func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet) (*enti
opts.DNSOptions = options
}

if flags.Changed("dns-option") {
options, err := flags.GetStringSlice("dns-option")
if err != nil {
return nil, err
}
opts.DNSOptions = append(opts.DNSOptions, options...)
}

if flags.Changed("dns-search") {
dnsSearches, err := flags.GetStringSlice("dns-search")
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions test/system/500-networking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -767,4 +767,14 @@ EOF
is "$output" "" "Should print no output"
}

@test "podman network rm --dns-option " {
dns_opt=dns$(random_string)
run_podman run --rm --dns-opt=${dns_opt} $IMAGE cat /etc/resolv.conf
is "$output" ".*options ${dns_opt}" "--dns-opt was added"

dns_opt=dns$(random_string)
run_podman run --rm --dns-option=${dns_opt} $IMAGE cat /etc/resolv.conf
is "$output" ".*options ${dns_opt}" "--dns-option was added"
}

# vim: filetype=sh

0 comments on commit b9c094a

Please sign in to comment.