Check for insecure-registry in dockerd command
@@ -37,12 +37,24 @@ function create-and-configure-insecure-registry() {
return
fi
+ local err=
if sudo test -f "${docker_daemon_config}"; then
echo <<EOF "Error: ${docker_daemon_config} exists and \
CONFIGURE_INSECURE_REGISTRY=${CONFIGURE_INSECURE_REGISTRY}. This script needs \
to add an 'insecure-registries' entry with host '${CONTAINER_REGISTRY_HOST}' to \
${docker_daemon_config}. Please make the necessary changes or backup and try again."
EOF
+ err=true
+ elif pgrep -a dockerd | grep -q 'insecure-registry'; then
+ echo <<EOF "Error: CONFIGURE_INSECURE_REGISTRY=${CONFIGURE_INSECURE_REGISTRY} \
+and about to write ${docker_daemon_config}, but dockerd is already configured with \
+an 'insecure-registry' command line option. Please make the necessary changes or disable \
+the command line option and try again."
+EOF
+ err=true
+ fi
+
+ if [[ "${err}" ]]; then
docker kill registry &> /dev/null
docker rm registry &> /dev/null
return 1
