mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
Merge pull request #16440 from n1hility/fix-registry-search
Use single unqualified search registry on Windows
This commit is contained in:
@ -36,7 +36,7 @@ var (
|
||||
const (
|
||||
ErrorSuccessRebootInitiated = 1641
|
||||
ErrorSuccessRebootRequired = 3010
|
||||
currentMachineVersion = 2
|
||||
currentMachineVersion = 3
|
||||
)
|
||||
|
||||
const containersConf = `[containers]
|
||||
@ -45,6 +45,9 @@ const containersConf = `[containers]
|
||||
cgroup_manager = "cgroupfs"
|
||||
`
|
||||
|
||||
const registriesConf = `unqualified-search-registries=["docker.io"]
|
||||
`
|
||||
|
||||
const appendPort = `grep -q Port\ %d /etc/ssh/sshd_config || echo Port %d >> /etc/ssh/sshd_config`
|
||||
|
||||
const configServices = `ln -fs /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service
|
||||
@ -314,6 +317,11 @@ func (v *MachineVM) migrateMachine(configPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Update older machines missing unqualified search config
|
||||
if err := configureRegistries(v, toDist(v.Name)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
v.Version = currentMachineVersion
|
||||
return v.writeConfig()
|
||||
}
|
||||
@ -554,6 +562,10 @@ func configureSystem(v *MachineVM, dist string) error {
|
||||
return fmt.Errorf("could not create containers.conf for guest OS: %w", err)
|
||||
}
|
||||
|
||||
if err := configureRegistries(v, dist); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := wslInvoke(dist, "sh", "-c", "echo wsl > /etc/containers/podman-machine"); err != nil {
|
||||
return fmt.Errorf("could not create podman-machine file for guest OS: %w", err)
|
||||
}
|
||||
@ -608,6 +620,15 @@ func enableUserLinger(v *MachineVM, dist string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func configureRegistries(v *MachineVM, dist string) error {
|
||||
cmd := "cat > /etc/containers/registries.conf.d/999-podman-machine.conf"
|
||||
if err := wslPipe(registriesConf, dist, "sh", "-c", cmd); err != nil {
|
||||
return fmt.Errorf("could not configure registries on guest OS: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func installScripts(dist string) error {
|
||||
if err := wslPipe(enterns, dist, "sh", "-c",
|
||||
"cat > /usr/local/bin/enterns; chmod 755 /usr/local/bin/enterns"); err != nil {
|
||||
|
Reference in New Issue
Block a user