mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
rootless: allow a per-user registries.conf file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -155,6 +155,8 @@ Hooks are not used when running in rootless mode.
|
||||
|
||||
registries.conf is the configuration file which specifies which container registries should be consulted when completing image names which do not include a registry or domain portion.
|
||||
|
||||
When Podman runs in rootless mode, the file `$HOME/.config/containers/registries.conf` is used.
|
||||
|
||||
## Rootless mode
|
||||
Podman can also be used as non-root user. When podman runs in rootless mode, an user namespace is automatically created.
|
||||
|
||||
|
@ -2,15 +2,27 @@ package registries
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/containers/image/pkg/sysregistries"
|
||||
"github.com/containers/image/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectatomic/libpod/pkg/rootless"
|
||||
)
|
||||
|
||||
// userRegistriesFile is the path to the per user registry configuration file.
|
||||
var userRegistriesFile = filepath.Join(os.Getenv("HOME"), ".config/containers/registries.conf")
|
||||
|
||||
// GetRegistries obtains the list of registries defined in the global registries file.
|
||||
func GetRegistries() ([]string, error) {
|
||||
registryConfigPath := ""
|
||||
|
||||
if rootless.IsRootless() {
|
||||
if _, err := os.Stat(userRegistriesFile); err == nil {
|
||||
registryConfigPath = userRegistriesFile
|
||||
}
|
||||
}
|
||||
|
||||
envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
|
||||
if len(envOverride) > 0 {
|
||||
registryConfigPath = envOverride
|
||||
@ -25,6 +37,11 @@ func GetRegistries() ([]string, error) {
|
||||
// GetInsecureRegistries obtains the list of insecure registries from the global registration file.
|
||||
func GetInsecureRegistries() ([]string, error) {
|
||||
registryConfigPath := ""
|
||||
|
||||
if _, err := os.Stat(userRegistriesFile); err == nil {
|
||||
registryConfigPath = userRegistriesFile
|
||||
}
|
||||
|
||||
envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
|
||||
if len(envOverride) > 0 {
|
||||
registryConfigPath = envOverride
|
||||
|
Reference in New Issue
Block a user