"Error authenticating: exit status 1" only when using dockerhub

I am not aware of any issues with the docker plugin on kubernetes. I just ran a quick test and was able to use the plugin without issue.

Error authenticating: exit status 1

There are only a few root causes that I am aware of for this error. The first is when the docker-in-docker daemon cannot start. This usually results in an error that looks like this:

failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.8.3 (legacy): can’t initialize iptables table `nat’: Permission denied (you must be root)

However, the below logs you provided (with debug: true in the yaml) indicate the daemon successfully started (see below snippet) so we can rule out this root cause.

time=“2021-01-21T14:15:59.634657433Z” level=info msg=“Daemon has completed initialization”
time=“2021-01-21T14:15:59.661299094Z” level=info msg=“API listen on /var/run/docker.sock”

There are a number of warnings in the above logs, however, these warnings are not abnormal. For example, see this build which is running on Drone Cloud and emits similar warning logs, but still succeeds.

The second root cause that I am aware of for this issue is an invalid username or password. The fact that the daemon successfully starts, and your username and password fail even when hard coded, would lead me to believe it is a problem with the credentials.

The third root cause that I am aware of for this issue is when you have networking issues that prevent the system from reaching the registry. This can include dns issues, but issues with self-signed certificates can also cause login to fail. If you are using self-signed certificates you can try adding insecure: true to your yaml configuration.


EDIT: the easiest way to debug this is to remove the username and password and then configure the plugin to perform a dry run.

kind: pipeline
type: kubernetes
name: deploy
steps:
  - name: build
    image: plugins/docker
    settings:
      auto_tag: true
      repo: dorfjungs/test-public-repo
+     dry_run: true
-     password: { from_secret: docker_user }
-     username: { from_secret: docker_pass }
-     debug: true

The dry run will attempt to build your image but will not login to dockerhub and will not publish to dockerhub. If the dry run is successful then we have isolated the problem to the login, which could indicate a problem with your dockerhub credentials or perhaps a problem with your networking or dns that is preventing docker from establishing a connection with dockerhub from inside the container.