Oracle Cloud Infrastructure Documentation

Pushing Images Using the Docker CLI

You use the Docker CLI to push images to Oracle Cloud Infrastructure Registry.

To push an image, you first use the docker tag command to create a copy of the local source image as a new image (the new image is actually just a reference to the existing source image). As a name for the new image, you specify the fully qualified path to the target location in Oracle Cloud Registry where you want to push the image, optionally including the name of a repository.

For example, assume you have a local image named acme-web-app:latest. Let's say you want to push this image to Oracle Cloud Infrastructure Registry with a name of acme-web-app:version2.0.test into a repository called project01 in the Ashburn region of the acme-dev tenancy. When you use the docker tag command, you'd name the new image with the fully qualified path to its destination. So in this case, you'd name the new image iad.ocir.io/acme-dev/project01/acme-web-app:version2.0.test. Subsequently, when you use the docker push command, the image's name ensures it is pushed to the correct destination.

Your permissions control the images you can push to Oracle Cloud Infrastructure Registry. You can push images to repositories you've created, and to repositories that the groups to which you belong have been granted access by appropriate identity policies. If you belong to the Administrators group, you can push images to any repository in the tenancy.

To push images to Oracle Cloud Infrastructure Registry using the Docker CLI:

  1. If you already have an auth token, go to the next step. Otherwise:

    1. In the top-right corner of the Console, open the User menu (User menu icon) and then click User Settings to view the details.
    2. On the Auth Tokens page, click Generate Token.
    3. Enter a friendly description for the auth token. Avoid entering confidential information.
    4. Click Generate Token. The new auth token is displayed.
    5. Copy the auth token immediately to a secure location from where you can retrieve it later, because you won't see the auth token again in the Console.
    6. Close the Generate Token dialog.
  2. In a terminal window on the client machine running Docker, log in to Oracle Cloud Infrastructure Registry by entering docker login <region-code>.ocir.io, where <region-code> corresponds to the code for the Oracle Cloud Infrastructure Registry region you're using, as follows:

    Region Code Region Name
    fra Frankfurt
    iad Ashburn
    lhr London
    phx Phoenix
    yyz Toronto

    For example, docker login iad.ocir.io

  3. When prompted, enter your username in the format <tenancy_name>/<username>. For example, acme-dev/jdoe@acme.com. If your tenancy is federated with Oracle Identity Cloud Service, use the format <tenancy-name>/oracleidentitycloudservice/<username>.
  4. When prompted, enter the auth token you copied earlier.
  5. Locate the image on the client machine that you want to push:

    1. In a terminal window on your client machine, enter docker images to list the available images.

      For example:

          
      $ docker images
      REPOSITORY        TAG              IMAGE ID      CREATED       SIZE
      acme-web-app      latest           8e0506e14874  2 hours ago   162.6 MB
      acme-web-app      version1.0       7d9495d03763  2 hours ago   162.6 MB
      <none>            <none>           6ebd328f833d  5 hours ago   162.6 MB
      hello-world       latest           80b84820d442  5 weeks ago   890 B
      					
    2. Find the image on the client machine that you want to push to Oracle Cloud Infrastructure Registry.

      In the output of the docker images command, look for the specific image that you want to push. You'll need to uniquely identify this image later, in one of the following ways:

      • using its id
      • using its name and tag, separated by a colon

      For example, you might have an image named acme-web-app on the client machine. In the output of the docker images command, look for the specific acme-web-app image that you want to push. You can uniquely identify that particular image in one of the following ways:

      • using its id (for example, 8e0506e14874)
      • using its name and tag, separated by a colon (for example acme-web-app:latest)
    3. Give a tag to the image that you're going to push to Oracle Cloud Infrastructure Registry by entering:

      docker tag <image-identifier> <target-tag>

      where:

      • <image-identifier> uniquely identifies the image, either using the image's id (for example, 8e0506e14874), or the image's name and tag separated by a colon (for example, acme-web-app:latest).
      • <target-tag> is in the format <region-code>.ocir.io/<tenancy-name>/<repos-name>/<image-name>:<tag> where:

        • <region-code> is one of fra, iad, lhr, phx, or yyz
        • ocir.io is the Oracle Cloud Infrastructure Registry name.
        • <tenancy-name> is the name of the tenancy that owns the repository to which you want to push the image (for example, acme-dev). Note that your user must have access to the tenancy.
        • <repo-name> (if specified) is the name of a repository to which you want to push the image (for example, project01). Note that specifying a repository is optional (see About Repositories).
        • <image-name> is the name you want to give the image in Oracle Cloud Infrastructure Registry (for example, acme-web-app).
        • <tag> is an image tag you want to give the image in Oracle Cloud Infrastructure Registry (for example, version2.0.test).

      For example, combining the previous examples, you might enter:

      docker tag 8e0506e14874 iad.ocir.io/acme-dev/project01/acme-web-app:version2.0.test
  6. Confirm that the Docker image has been correctly tagged on the client machine by entering docker images and verifying that the list of images includes an image with the tag you specified.

    For example:

    $ docker images
    REPOSITORY                                  TAG                   IMAGE ID      CREATED       SIZE
    iad.ocir.io/acme-dev/project01/acme-web-app version2.0.test       8e0506e14874  1 minute ago  162.6 MB
    acme-web-app                                latest                8e0506e14874  2 hours ago   162.6 MB
    acme-web-app                                version1.0            7d9495d03763  2 hours ago   162.6 MB
    <none>                                      <none>                6ebd328f833d  5 hours ago   162.6 MB
    hello-world                                 latest                80b84820d442  5 weeks ago   890 B
    					
  7. Push the Docker image from the client machine to Oracle Cloud Infrastructure Registry by entering:

    docker push <target-tag>

    where <target-tag> is in the format <region-code>.ocir.io/<tenancy-name>/<repos-name>/<image-name>:<tag> where:

    • <region-code> is one of fra, iad, lhr, phx, or yyz
    • ocir.io is the Oracle Cloud Infrastructure Registry name.
    • <tenancy-name> is the name of the tenancy that owns the repository to which you want to push the image (for example, acme-dev). Note that your user must have access to the tenancy.
    • <repo-name> (if specified) is the name of a repository to which you want to push the image (for example, project01). Note that specifying a repository is optional (see About Repositories).
    • <image-name> is the name you want to give the image in Oracle Cloud Infrastructure Registry (for example, acme-web-app).
    • <tag> is an image tag you want to give the image in Oracle Cloud Infrastructure Registry (for example, version2.0.test).

    For example:

    docker push iad.ocir.io/acme-dev/project01/acme-web-app:version2.0.test