---
title: How to use a public registry
description: Canonical makes open source secure, reliable and easy to use, providing
  support for Ubuntu and a portfolio of enterprise-grade technologies. Founded in
  2004, Canonical operates globally with team members in over 80 countries.
url: https://canonical.com/microk8s/docs/registry-public?format=md
---

*Submit*

# How to use a public registry

After building an image we can push it to one of the mainstream public registries. For this example we have created an account with <https://hub.docker.com/> with the username `kjackal`.

First we run the login command:

```
docker login
```

Docker will ask for a Docker ID and password to complete the login.

```
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: kjackal
Password: *******
```

Pushing to the registry requires that the image is tagged with `your-hub-username/image-name:tag`. We can either add proper tagging during build:

```
docker build . -t kjackal/mynginx:public
```

Or tag an already existing image using the image ID. Obtain the ID by running:

```
docker images
```

The ID is listed in the output:

```
REPOSITORY          TAG                 IMAGE ID            SIZE
mynginx             local               1fe3d8f47868        16.1MB
....
```

Then use the `tag` command:

```
docker tag 1fe3d8f47868 kjackal/mynginx:public
```

Now that the image is tagged correctly, it can be pushed to the registry:

```
docker push kjackal/mynginx
```

At this point we are ready to `microk8s kubectl apply -f` a deployment with our image:

```
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: kjackal/mynginx:public
        ports:
        - containerPort: 80
```

We refer to the image as `image: kjackal/mynginx:public`. Kubernetes will search for the image in its default registry, `docker.io`.

Last updated 4 years ago. [Help improve this document in the forum](https://discuss.kubernetes.io/t/how-to-use-a-public-registry/11271).
