diff options
author | baude <bbaude@redhat.com> | 2020-10-29 15:54:33 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2020-11-09 15:08:58 -0600 |
commit | b7b5b6f8e3072530f4c3fc07e5960e54c90729b5 (patch) | |
tree | 01352a9b52f5e6cc3b0c78390036010088e3097a /cmd/podman/common/netflags.go | |
parent | 110a1d8f25c87739afe790ac2bc461937f17222a (diff) | |
download | podman-b7b5b6f8e3072530f4c3fc07e5960e54c90729b5.tar.gz podman-b7b5b6f8e3072530f4c3fc07e5960e54c90729b5.tar.bz2 podman-b7b5b6f8e3072530f4c3fc07e5960e54c90729b5.zip |
network aliases for container creation
podman can now support adding network aliases when running containers
(--network-alias). It requires an updated dnsname plugin as well as an
updated ocicni to work properly.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/common/netflags.go')
-rw-r--r-- | cmd/podman/common/netflags.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go index 1b8297c36..935a5f7b9 100644 --- a/cmd/podman/common/netflags.go +++ b/cmd/podman/common/netflags.go @@ -43,6 +43,10 @@ func GetNetFlags() *pflag.FlagSet { "network", containerConfig.NetNS(), "Connect a container to a network", ) + netFlags.StringSlice( + "network-alias", []string{}, + "Add network-scoped alias for the container", + ) netFlags.StringSliceP( "publish", "p", []string{}, "Publish a container's port, or a range of ports, to the host (default [])", @@ -158,6 +162,9 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) { } opts.NoHosts, err = cmd.Flags().GetBool("no-hosts") + if err != nil { + return nil, err + } if cmd.Flags().Changed("network") { network, err := cmd.Flags().GetString("network") @@ -181,5 +188,12 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) { opts.CNINetworks = cniNets } + aliases, err := cmd.Flags().GetStringSlice("network-alias") + if err != nil { + return nil, err + } + if len(aliases) > 0 { + opts.Aliases = aliases + } return &opts, err } |