Pushing Docker image to Oracle Container Registry
Tags: oracle, cloud, docker
Published: 2023-06-11 15:13:54

Oftencase the Docker hub is where general open-source developers store their Docker images. But occasionally when you want to use the Oracle Cloud Infrastructure, you'd want to upload those images to your cloud tenancy's private Container Registry to simplify your development to production workflow. Here's how you do it.

_Note: To use this service, you must upgrade to a paid account._

## How to connect to the Container Registry

**1.  Find your tenancy namespace in Oracle Cloud > Profile Picture > Tenancy, e.g. iddriaq7lag549**

![OCI console screenshot of Tenancy details page showing namepspace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eac0rvki11ztg8f1w8pe.png)

**2\. Create an Auth Token in your Oracle Cloud > Profile > My Profile > User Settings > Auth Tokens. This will be your Docker login password.**

![Auth Token creation page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p3dut37yozlwx0p8cghv.png)

**3\. Login to the Container Registry on Docker using:**

```sh
docker login iad.ocir.io
```

If you are not using the Ashburn (IAD) region, please refer to this [list](https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryprerequisites.htm#regional-availability) for your docker login URL.

**4\. The Terminal will prompt you for your username and password. Your username and password will look like this:**

Username: `idrriaq7lag5/fdurrani@mythics.com`
Password: `DBY75ZmVsc_v3!Qg6duC`

where:
- `idrriaq7lag5` is the tenancy namespace you found in Step 1
- `fdurrani@mythics.com` is your Oracle Cloud login email
- the password is the Auth Token retrieved in Step 2

Of course, you can also do a one-liner:
```sh
docker login -u 'idrriaq7lag5/fdurrani@mythics.com' -p 'DBY75ZmVsc_v3!Qg6duC' https://iad.ocir.io
```

**5\. Now you can build, push, and pull your Docker images as usual using:**

```sh
docker build -t iad.ocir.io/idrriaq7lag5/myImage:latest .
docker push iad.ocir.io/idrriaq7lag5/myImage:latest
docker pull iad.ocir.io/idrriaq7lag5/myImage:latest
```

You will find the pushed image in the Container Registry (`root` compartment). You can move the image to any other compartment afterwards.

**6\. If you want to logout, simply:**
```sh
docker logout iad.ocir.io
```

And that's a short guide to using Docker for Oracle Cloud's Container Registry.

## References:
1. [Overview of Container Registry](https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryoverview.htm)
2. [Logging in to Oracle Cloud Infrastructure Registry](https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionslogintoocir.htm)

---

***Safe harbor statement***
The information provided on this channel/article/story is solely intended for informational purposes and cannot be used as a part of any contractual agreement. The content does not guarantee the delivery of any material, code, or functionality, and should not be the sole basis for making purchasing decisions. The postings on this site are my own and do not necessarily reflect the views or work of Oracle or Mythics, LLC.

*This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).*