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

Adding simple Podman insecure registry support #2060

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
21 changes: 19 additions & 2 deletions hack/registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set -o errexit
set -o nounset
set -o pipefail

CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
export TERM="${TERM:-dumb}"

main() {
Expand All @@ -16,18 +17,34 @@ main() {

echo "${em}Configuring for CI...${me}"

set_registry_insecure

# Check the value of CONTAINER_ENGINE
echo 'Setting registry as trusted local-only'
if [ "$CONTAINER_ENGINE" == "docker" ]; then
set_registry_insecure
elif [ "$CONTAINER_ENGINE" == "podman" ]; then
set_registry_insecure_podman
fi

echo "${em}DONE${me}"

}

set_registry_insecure() {
echo 'Setting registry as trusted local-only'
patch=".\"insecure-registries\" = [\"localhost:50000\""]
sudo jq "$patch" /etc/docker/daemon.json > /tmp/daemon.json.tmp && sudo mv /tmp/daemon.json.tmp /etc/docker/daemon.json
sudo service docker restart
}

set_registry_insecure_podman() {
FILE="/etc/containers/registries.conf"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be local readonly var.


# Check if the section exists
if ! sudo grep -q "\[\[registry-insecure-local\]\]" "$FILE"; then
# Append the new section to the file
echo -e "\n[[registry-insecure-local]]\nlocation = \"localhost:50000\"\ninsecure = true" | sudo tee -a "$FILE" > /dev/null
fi
}

main "$@"

Loading