How to configure Docker to Enable Push to Public Registry?

Article ID:215906478
1 minute readKnowledge base

Issue

  • Build fails when using [Docker Build and Publish plugin] to push to a public registry like DockerHub.

  • Error message: Do you really want to push to public registry?EOF

Environment

  • CloudBees Jenkins Enterprise

  • Docker shipped with Red Hat Enterprise Linux 7.1+

Resolution

Root Cause

In Red Hat Enterprise Linux 7.1, experimental features have been introduced in the Docker package that is shipped within the distribution. It includes options to manage which registries the docker daemon can connect to. More information can be found in this article: Understanding the Changes to ‘docker search’ and ‘docker pull’ in Red Hat Enterprise Linux 7.1.

In particular, there is an option --confirm-def-push, which makes Docker ask for a confirmation before pushing to a public registry. The default value is true.

When trying to push a docker image to a public registry, the user is prompted with the following message: Do you really want to push to public registry?. This prompt makes the build fail when using the [Docker Build and Publish plugin]:

Do you really want to push to public registry? [y/n]: EOF
Build step 'Docker Build and Publish' marked build as failure

Solution

In order to fix this, you need to configure the docker daemon. Add the option --confirm-def-push=false to the OPTIONS variable when starting the docker daemon. The simplest way is to edit the OPTIONS vaiable in the docker configuration file /etc/sysconfig/docker. If the configuration file does not exists, create it and add the following:

OPTIONS="--confirm-def-push=true"

More information about how to configure docker can be found at https://docs.docker.com/config/daemon/#configuring-docker.