summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/main_local.go2
-rw-r--r--docs/source/markdown/podman.1.md39
-rw-r--r--libpod/networking_linux.go34
-rw-r--r--libpod/options.go8
-rw-r--r--test/e2e/run_networking_test.go14
5 files changed, 72 insertions, 25 deletions
diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go
index 0484e3cf0..968d7331a 100644
--- a/cmd/podman/main_local.go
+++ b/cmd/podman/main_local.go
@@ -69,7 +69,7 @@ func init() {
rootCmd.PersistentFlags().StringArrayVar(&MainGlobalOpts.StorageOpts, "storage-opt", []string{}, "Used to pass an option to the storage driver")
rootCmd.PersistentFlags().BoolVar(&MainGlobalOpts.Syslog, "syslog", false, "Output logging information to syslog as well as the console")
- rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.TmpDir, "tmpdir", "", "Path to the tmp directory")
+ rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.TmpDir, "tmpdir", "", "Path to the tmp directory for libpod state content.\n\nNote: use the environment variable 'TMPDIR' to change the temporary storage location for container images, '/var/tmp'.\n")
rootCmd.PersistentFlags().BoolVar(&MainGlobalOpts.Trace, "trace", false, "Enable opentracing output")
}
diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md
index f6fa1a457..c62f54fbb 100644
--- a/docs/source/markdown/podman.1.md
+++ b/docs/source/markdown/podman.1.md
@@ -21,10 +21,6 @@ created by the other.
## GLOBAL OPTIONS
-**--help**, **-h**
-
-Print usage statement
-
**--cgroup-manager**=*manager*
CGroup manager to use for container cgroups. Supported values are cgroupfs or systemd. Default is systemd unless overridden in the libpod.conf file.
@@ -32,6 +28,17 @@ CGroup manager to use for container cgroups. Supported values are cgroupfs or sy
Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.
+**--cni-config-dir**
+Path of the configuration directory for CNI networks. (Default: `/etc/cni/net.d`)
+
+**--config**
+Path of a libpod config file detailing container server configuration options
+
+Default libpod config file is /usr/share/containers/libpod.conf. Override file is in /etc/containers/libpod.conf. In rootless mode the config file will be read from $HOME/.config/containers/libpod.conf.
+
+**--conmon**
+Path of the conmon binary (Default path is configured in `libpod.conf`)
+
**--cpu-profile**=*path*
Path to where the cpu performance results should be written
@@ -40,6 +47,10 @@ Path to where the cpu performance results should be written
Backend to use for storing events. Allowed values are **file**, **journald**, and **none**.
+**--help**, **-h**
+
+Print usage statement
+
**--hooks-dir**=*path*
Each `*.json` file in the path configures a hook for Podman containers. For more details on the syntax of the JSON files and the semantics of hook injection, see `oci-hooks(5)`. Podman and libpod currently support both the 1.0.0 and 0.1.0 hook schemas, although the 0.1.0 schema is deprecated.
@@ -58,30 +69,30 @@ Podman and libpod currently support an additional `precreate` state which is cal
**--log-level**=*level*
-Log messages above specified level: debug, info, warn, error (default), fatal or panic
+Log messages above specified level: debug, info, warn, error (default), fatal or panic (default: "error")
**--namespace**=*namespace*
Set libpod namespace. Namespaces are used to separate groups of containers and pods in libpod's state.
When namespace is set, created containers and pods will join the given namespace, and only containers and pods in the given namespace will be visible to Podman.
+**--network-cmd-path**=*path*
+Path to the command binary to use for setting up a network. It is currently only used for setting up a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable.
+
**--root=***value*
Storage root dir in which data, including images, is stored (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users).
-Default root dir is configured in /etc/containers/storage.conf.
+Default root dir is configured in `/etc/containers/storage.conf`.
**--runroot**=*value*
Storage state directory where all state information is stored (default: "/var/run/containers/storage" for UID 0, "/var/run/user/$UID/run" for other users).
-Default state dir is configured in /etc/containers/storage.conf.
+Default state dir is configured in `/etc/containers/storage.conf`.
**--runtime**=*value*
Name of the OCI runtime as specified in libpod.conf or absolute path to the OCI compatible binary used to run containers.
-**--network-cmd-path**=*path*
-Path to the command binary to use for setting up a network. It is currently only used for setting up a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable.
-
**--storage-driver**=*value*
Storage driver. The default storage driver for UID 0 is configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode), and is *vfs* for non-root users when *fuse-overlayfs* is not available. The `STORAGE_DRIVER` environment variable overrides the default. The --storage-driver specified driver overrides all.
@@ -95,10 +106,16 @@ Storage driver option, Default storage driver options are configured in /etc/con
**--syslog**
-output logging information to syslog as well as the console
+Output logging information to syslog as well as the console.
On remote clients, logging is directed to the file ~/.config/containers/podman.log
+**--tmpdir**
+
+Path to the tmp directory, for libpod runtime content.
+
+NOTE --tmpdir is not used for the temporary storage of downloaded images. Use the environment variable `TMPDIR` to change the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`.
+
**--version**, **-v**
Print the version
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index cba7b636a..a68338dbb 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -29,19 +29,40 @@ import (
// Get an OCICNI network config
func (r *Runtime) getPodNetwork(id, name, nsPath string, networks []string, ports []ocicni.PortMapping, staticIP net.IP, staticMAC net.HardwareAddr) ocicni.PodNetwork {
- defaultNetwork := r.netPlugin.GetDefaultNetworkName()
+ var networkKey string
+ if len(networks) > 0 {
+ // This is inconsistent for >1 network, but it's probably the
+ // best we can do.
+ networkKey = networks[0]
+ } else {
+ networkKey = r.netPlugin.GetDefaultNetworkName()
+ }
network := ocicni.PodNetwork{
Name: name,
Namespace: name, // TODO is there something else we should put here? We don't know about Kube namespaces
ID: id,
NetNS: nsPath,
RuntimeConfig: map[string]ocicni.RuntimeConfig{
- defaultNetwork: {PortMappings: ports},
+ networkKey: {PortMappings: ports},
},
}
+ // If we have extra networks, add them
+ if len(networks) > 0 {
+ network.Networks = make([]ocicni.NetAttachment, len(networks))
+ for i, netName := range networks {
+ network.Networks[i].Name = netName
+ }
+ }
+
if staticIP != nil || staticMAC != nil {
- network.Networks = []ocicni.NetAttachment{{Name: defaultNetwork}}
+ // For static IP or MAC, we need to populate networks even if
+ // it's just the default.
+ if len(networks) == 0 {
+ // If len(networks) == 0 this is guaranteed to be the
+ // default network.
+ network.Networks = []ocicni.NetAttachment{{Name: networkKey}}
+ }
var rt ocicni.RuntimeConfig = ocicni.RuntimeConfig{PortMappings: ports}
if staticIP != nil {
rt.IP = staticIP.String()
@@ -50,12 +71,7 @@ func (r *Runtime) getPodNetwork(id, name, nsPath string, networks []string, port
rt.MAC = staticMAC.String()
}
network.RuntimeConfig = map[string]ocicni.RuntimeConfig{
- defaultNetwork: rt,
- }
- } else {
- network.Networks = make([]ocicni.NetAttachment, len(networks))
- for i, netName := range networks {
- network.Networks[i].Name = netName
+ networkKey: rt,
}
}
diff --git a/libpod/options.go b/libpod/options.go
index bfbbb9e2d..f7f14eb26 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1041,8 +1041,8 @@ func WithStaticIP(ip net.IP) CtrCreateOption {
return errors.Wrapf(define.ErrInvalidArg, "cannot set a static IP if the container is not creating a network namespace")
}
- if len(ctr.config.Networks) != 0 {
- return errors.Wrapf(define.ErrInvalidArg, "cannot set a static IP if joining additional CNI networks")
+ if len(ctr.config.Networks) > 1 {
+ return errors.Wrapf(define.ErrInvalidArg, "cannot set a static IP if joining more than 1 CNI network")
}
ctr.config.StaticIP = ip
@@ -1066,8 +1066,8 @@ func WithStaticMAC(mac net.HardwareAddr) CtrCreateOption {
return errors.Wrapf(define.ErrInvalidArg, "cannot set a static MAC if the container is not creating a network namespace")
}
- if len(ctr.config.Networks) != 0 {
- return errors.Wrapf(define.ErrInvalidArg, "cannot set a static MAC if joining additional CNI networks")
+ if len(ctr.config.Networks) > 1 {
+ return errors.Wrapf(define.ErrInvalidArg, "cannot set a static MAC if joining more than 1 CNI network")
}
ctr.config.StaticMAC = mac
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index ec12f709a..5e587b198 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -232,4 +232,18 @@ var _ = Describe("Podman run networking", func() {
Expect(session).To(ExitWithError())
Expect(session.ErrorToString()).To(ContainSubstring("stat /run/netns/xxy: no such file or directory"))
})
+
+ It("podman run in custom CNI network with --static-ip", func() {
+ SkipIfRootless()
+ netName := "podmantestnetwork"
+ ipAddr := "10.20.30.128"
+ create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.20.30.0/24", netName})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(BeZero())
+
+ run := podmanTest.Podman([]string{"run", "-t", "-i", "--rm", "--net", netName, "--ip", ipAddr, ALPINE, "ip", "addr"})
+ run.WaitWithDefaultTimeout()
+ Expect(run.ExitCode()).To(BeZero())
+ Expect(run.OutputToString()).To(ContainSubstring(ipAddr))
+ })
})