Answers: <ol>
  <li>Update your <code>/etc/rancher/k3s/registries.yaml</code> to
  <pre class="lang-yaml prettyprint-override"><code>configs:
    registry-1.docker.io:
      auth:
        username: evancarroll
        password: TOKENHIDDEN
  </code></pre>
  </li>
  <li>Restart k3s, <code>sudo systemctl force-reload k3s</code>.</li>
  </ol>
  <p>You can confirm the changes were accepted by checking that your key exists in <code>/var/lib/rancher/k3s/agent/etc/containerd/config.toml</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-06-15T21:36:58.620Z
Answers: 2022-06-15T23:08:10.137Z
Answers: 2022-06-15T23:08:10.137Z
Answers: Evan Carroll
Body: <p>In <code>jornalctl -u k3s</code>, I see a bunch of errors like this</p>
  <blockquote>
  <p>429 Too Many Requests - Server message: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: <a href="https://www.docker.com/increase-rate-limit" rel="nofollow noreferrer">https://www.docker.com/increase-rate-limit</a></p>
  </blockquote>
  <p>When I check the associate pods, I see</p>
  <blockquote>
  <p>Error from server (BadRequest): container &quot;foo&quot; in pod &quot;bar&quot; is waiting to start: trying and failing to pull image</p>
  </blockquote>
  <p>How can I set up k3s to use an authenticate login to DockerHub? I don't see a <code>docker login</code>, and I've tried probably 20 different things none of which worked. I can confirm this username and password works with <a href="https://devops.stackexchange.com/q/16152/18965"><code>--creds</code> to either <code>crictl</code> or <code>ctr</code></a>. But it doesn't work when I try to put it in a config file. I've tried to playing with</p>
  <ul>
  <li><code>/etc/rancher/k3s/registries.yaml</code> and restarting.</li>
  <li>that seems to generate a new <code>/var/lib/rancher/k3s/agent/etc/containerd/config.toml</code>, I've tried playing with that file too directly</li>
  </ul>
  <p>None of this seems to make any difference. I've tried testing with <code>k3s kubectl run</code> and also with <a href="https://devops.stackexchange.com/q/16152/18965"><code>k3s crt</code> and <code>k3s crictl</code> without providing <code>--creds</code></a>, and none of these change the error that's returned.</p>
  <p>My token has full access at <a href="https://hub.docker.com/settings/security" rel="nofollow noreferrer">https://hub.docker.com/settings/security</a></p>
  
Tags: <dockerhub><k3s>
Title: How do I get k3s to authenticate with Docker Hub?
UserDisplayName: Evan Carroll
ThreadText: # How do I get k3s to authenticate with Docker Hub?
  
  (Asked by: username_0 on 2022-06-14)
  
  In `jornalctl -u k3s`, I see a bunch of errors like this
  
  > 429 Too Many Requests - Server message: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: <https://www.docker.com/increase-rate-limit>
  
  When I check the associate pods, I see
  
  > Error from server (BadRequest): container "foo" in pod "bar" is waiting to start: trying and failing to pull image
  
  How can I set up k3s to use an authenticate login to DockerHub? I don't see a `docker login`, and I've tried probably 20 different things none of which worked. I can confirm this username and password works with [`--creds` to either `crictl` or `ctr`](https://devops.stackexchange.com/q/16152/18965). But it doesn't work when I try to put it in a config file. I've tried to playing with
  
  * `/etc/rancher/k3s/registries.yaml` and restarting.
  * that seems to generate a new `/var/lib/rancher/k3s/agent/etc/containerd/config.toml`, I've tried playing with that file too directly
  
  None of this seems to make any difference. I've tried testing with `k3s kubectl run` and also with [`k3s crt` and `k3s crictl` without providing `--creds`](https://devops.stackexchange.com/q/16152/18965), and none of these change the error that's returned.
  
  My token has full access at <https://hub.docker.com/settings/security>
  
  **Tags:** dockerhub, k3s
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-06-15. Score: 3 | Accepted answer
  
  1. Update your `/etc/rancher/k3s/registries.yaml` to
  
     ```yaml
     configs:
       registry-1.docker.io:
         auth:
           username: username_0
           password: TOKENHIDDEN
  
     ```
  2. Restart k3s, `sudo systemctl force-reload k3s`.
  
  You can confirm the changes were accepted by checking that your key exists in `/var/lib/rancher/k3s/agent/etc/containerd/config.toml`.
  
  
  ---
  
  