mirror of
https://github.com/containers/podman.git
synced 2025-06-17 23:20:59 +08:00
Merge pull request #2538 from giuseppe/slirp4netns-path
libpod: allow to configure path to the slirp4netns binary
This commit is contained in:
@ -25,6 +25,7 @@ type MainFlags struct {
|
|||||||
StorageOpts []string
|
StorageOpts []string
|
||||||
Syslog bool
|
Syslog bool
|
||||||
Trace bool
|
Trace bool
|
||||||
|
NetworkCmdPath string
|
||||||
|
|
||||||
Config string
|
Config string
|
||||||
CpuProfile string
|
CpuProfile string
|
||||||
|
@ -86,6 +86,9 @@ func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, err
|
|||||||
if c.Flags().Changed("tmpdir") {
|
if c.Flags().Changed("tmpdir") {
|
||||||
options = append(options, libpod.WithTmpDir(c.GlobalFlags.TmpDir))
|
options = append(options, libpod.WithTmpDir(c.GlobalFlags.TmpDir))
|
||||||
}
|
}
|
||||||
|
if c.Flags().Changed("network-cmd-path") {
|
||||||
|
options = append(options, libpod.WithNetworkCmdPath(c.GlobalFlags.NetworkCmdPath))
|
||||||
|
}
|
||||||
|
|
||||||
if c.Flags().Changed("cgroup-manager") {
|
if c.Flags().Changed("cgroup-manager") {
|
||||||
options = append(options, libpod.WithCgroupManager(c.GlobalFlags.CGroupManager))
|
options = append(options, libpod.WithCgroupManager(c.GlobalFlags.CGroupManager))
|
||||||
|
@ -104,6 +104,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CpuProfile, "cpu-profile", "", "Path for the cpu profiling results")
|
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CpuProfile, "cpu-profile", "", "Path for the cpu profiling results")
|
||||||
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.Config, "config", "", "Path of a libpod config file detailing container server configuration options")
|
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.Config, "config", "", "Path of a libpod config file detailing container server configuration options")
|
||||||
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.ConmonPath, "conmon", "", "Path of the conmon binary")
|
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.ConmonPath, "conmon", "", "Path of the conmon binary")
|
||||||
|
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.NetworkCmdPath, "network-cmd-path", "", "Path to the command for configuring the network")
|
||||||
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CniConfigDir, "cni-config-dir", "", "Path of the configuration directory for CNI networks")
|
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.CniConfigDir, "cni-config-dir", "", "Path of the configuration directory for CNI networks")
|
||||||
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.DefaultMountsFile, "default-mounts-file", "", "Path to default mounts file")
|
rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.DefaultMountsFile, "default-mounts-file", "", "Path to default mounts file")
|
||||||
rootCmd.PersistentFlags().MarkHidden("defaults-mount-file")
|
rootCmd.PersistentFlags().MarkHidden("defaults-mount-file")
|
||||||
|
@ -91,6 +91,10 @@ libpod to manage containers.
|
|||||||
Directory where named volumes will be created in using the default volume driver.
|
Directory where named volumes will be created in using the default volume driver.
|
||||||
By default this will be configured relative to where containers/storage stores containers.
|
By default this will be configured relative to where containers/storage stores containers.
|
||||||
|
|
||||||
|
**network_cmd_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.
|
||||||
|
|
||||||
## FILES
|
## FILES
|
||||||
`/usr/share/containers/libpod.conf`, default libpod configuration path
|
`/usr/share/containers/libpod.conf`, default libpod configuration path
|
||||||
|
|
||||||
|
@ -72,6 +72,9 @@ Default state dir is configured in /etc/containers/storage.conf.
|
|||||||
|
|
||||||
Name of the OCI runtime as specified in libpod.conf or absolute path to the OCI compatible binary used to run containers.
|
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**=**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.
|
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.
|
||||||
|
@ -139,10 +139,15 @@ func (r *Runtime) setupRootlessNetNS(ctr *Container) (err error) {
|
|||||||
defer ctr.rootlessSlirpSyncR.Close()
|
defer ctr.rootlessSlirpSyncR.Close()
|
||||||
defer ctr.rootlessSlirpSyncW.Close()
|
defer ctr.rootlessSlirpSyncW.Close()
|
||||||
|
|
||||||
path, err := exec.LookPath("slirp4netns")
|
path := r.config.NetworkCmdPath
|
||||||
if err != nil {
|
|
||||||
logrus.Errorf("could not find slirp4netns, the network namespace won't be configured: %v", err)
|
if path == "" {
|
||||||
return nil
|
var err error
|
||||||
|
path, err = exec.LookPath("slirp4netns")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Errorf("could not find slirp4netns, the network namespace won't be configured: %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
syncR, syncW, err := os.Pipe()
|
syncR, syncW, err := os.Pipe()
|
||||||
|
@ -193,6 +193,20 @@ func WithConmonEnv(environment []string) RuntimeOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithNetworkCmdPath specifies the path to the slirp4netns binary which manages the
|
||||||
|
// runtime.
|
||||||
|
func WithNetworkCmdPath(path string) RuntimeOption {
|
||||||
|
return func(rt *Runtime) error {
|
||||||
|
if rt.valid {
|
||||||
|
return ErrRuntimeFinalized
|
||||||
|
}
|
||||||
|
|
||||||
|
rt.config.NetworkCmdPath = path
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithCgroupManager specifies the manager implementation name which is used to
|
// WithCgroupManager specifies the manager implementation name which is used to
|
||||||
// handle cgroups for containers.
|
// handle cgroups for containers.
|
||||||
// Current valid values are "cgroupfs" and "systemd".
|
// Current valid values are "cgroupfs" and "systemd".
|
||||||
|
@ -217,6 +217,8 @@ type RuntimeConfig struct {
|
|||||||
EnablePortReservation bool `toml:"enable_port_reservation"`
|
EnablePortReservation bool `toml:"enable_port_reservation"`
|
||||||
// EnableLabeling indicates wether libpod will support container labeling
|
// EnableLabeling indicates wether libpod will support container labeling
|
||||||
EnableLabeling bool `toml:"label"`
|
EnableLabeling bool `toml:"label"`
|
||||||
|
// NetworkCmdPath is the path to the slirp4netns binary
|
||||||
|
NetworkCmdPath string `toml:"network_cmd_path"`
|
||||||
|
|
||||||
// NumLocks is the number of locks to make available for containers and
|
// NumLocks is the number of locks to make available for containers and
|
||||||
// pods.
|
// pods.
|
||||||
|
Reference in New Issue
Block a user