Skip to content

Commit

Permalink
Adding simple Podman insecure registry support (#2060)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
  • Loading branch information
matzew committed Oct 30, 2023
1 parent bc1acd1 commit a4680b2
Showing 1 changed file with 19 additions and 2 deletions.
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"

# 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 "$@"

0 comments on commit a4680b2

Please sign in to comment.