Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If CONTAINER_HOST env variable is set default podman --remote=true #11978

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,15 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
lFlags.StringVar(&opts.Identity, identityFlagName, ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
_ = cmd.RegisterFlagCompletionFunc(identityFlagName, completion.AutocompleteDefault)

lFlags.BoolVarP(&opts.Remote, "remote", "r", false, "Access remote Podman service (default false)")
remote := false
if env, ok := os.LookupEnv("CONTAINER_HOST"); ok {
logrus.Infof("CONTAINER_HOST==%q, defaulting to '--remote=true'", env)
remote = true
} else if env, ok := os.LookupEnv("CONTAINER_CONNECTION"); ok {
logrus.Infof("CONTAINER_CONNECTION==%q, defaulting to '--remote=true'", env)
remote = true
}
lFlags.BoolVarP(&opts.Remote, "remote", "r", remote, "Access remote Podman service")
pFlags := cmd.PersistentFlags()
if registry.IsRemote() {
if err := lFlags.MarkHidden("remote"); err != nil {
Expand Down
22 changes: 22 additions & 0 deletions docs/source/markdown/podman-remote.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The `containers.conf` file should be placed under `$HOME/.config/containers/cont

Remote connection name

Overrides environment variable `CONTAINER_CONNECTION` if set.

#### **--help**, **-h**

Print usage statement
Expand Down Expand Up @@ -71,6 +73,26 @@ URL value resolution precedence:

Print the version

## Environment Variables

Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the `podman` commands.

#### **CONTAINERS_CONF**

Set default locations of containers.conf file

#### **CONTAINER_CONNECTION**

Set default `--connection` value to access Podman service.

#### **CONTAINER_HOST**

Set default `--url` value to access Podman service.

#### **CONTAINER_SSHKEY**

Set default `--identity` path to ssh key file value used to access Podman service.

## Exit Status

The exit code from `podman` gives information about why the container
Expand Down
57 changes: 55 additions & 2 deletions docs/source/markdown/podman.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ When namespace is set, created containers and pods will join the given namespace
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.

#### **--remote**, **-r**
Access Podman service will be remote
Remote connections use local containers.conf for default.
When true, access to the Podman service will be remote. Defaults to false.
Settings can be modified in the containers.conf file. If the CONTAINER_HOST
environment variable is set, the remote option defaults to true.

#### **--url**=*value*
URL to access Podman service (default from `containers.conf`, rootless `unix://run/user/$UID/podman/podman.sock` or as root `unix://run/podman/podman.sock`).
Expand Down Expand Up @@ -172,6 +173,58 @@ Print the version

Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the `podman` commands.

#### **CONTAINERS_CONF**

Set default locations of containers.conf file

#### **CONTAINERS_REGISTRIES_CONF**

Set default location of the registries.conf file.

#### **CONTAINERS_STORAGE_CONF**

Set default location of the storage.conf file.

#### **CONTAINER_CONNECTION**

Override default `--connection` value to access Podman service. Also enabled --remote option.

#### **CONTAINER_HOST**

Set default `--url` value to access Podman service. Also enabled --remote option.

#### **CONTAINER_SSHKEY**

Set default `--identity` path to ssh key file value used to access Podman service.

#### **STORAGE_DRIVER**

Set default `--storage-driver` value.

#### **STORAGE_OPTS**

Set default `--storage-opts` value.

#### **TMPDIR**

Set the the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`.

#### **XDG_CONFIG_HOME**

In Rootless mode configuration files are read from `XDG_CONFIG_HOME` when
specified, otherwise in the home directory of the user under
`$HOME/.config/containers`.

#### **XDG_DATA_HOME**

In Rootless mode images are pulled under `XDG_DATA_HOME` when specified,
otherwise in the home directory of the user under
`$HOME/.local/share/containers/storage`.

#### **XDG_RUNTIME_DIR**

In Rootless mode temporary configuration data is stored in `${XDG_RUNTIME_DIR}/containers`.

## Remote Access

The Podman command can be used with remote services using the `--remote` flag. Connections can
Expand Down
9 changes: 9 additions & 0 deletions test/system/001-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ function setup() {
is "$output" "Error: unknown flag: --remote" "podman version --remote"
}

@test "podman-remote: defaults" {
if is_remote; then
skip "only applicable on a local run"
fi

CONTAINER_HOST=foobar run_podman --log-level=info --help
is "$output" ".*defaulting to '--remote=true'" "CONTAINER_HOST sets --remote true"
}

# Check that just calling "podman-remote" prints the usage message even
# without a running endpoint. Use "podman --remote" for this as this works the same.
@test "podman-remote: check for command usage message without a running endpoint" {
Expand Down