Pushing a Docker Image to a Docker Repository

When you want to store a new or updated image in a Docker repository, you can use the Oracle Container Cloud Service Container Console to add a tag to the image and then push it to the repository.

For example, you might have pulled the latest version of an application from Docker Hub, updated the local version and stored it in your local Docker repository as a new image, and then used the Container Console to deploy the image as a service to test it. If the image passes the tests, you’ll want to push the new version to Docker Hub to replace the previous version by giving it the ‘latest’ tag.

You can use tags to push an image to any repository in any registry, not just to the registry it was originally pulled from. Note that a definition of the registry containing the repository to which you want to push the image must already exist in Oracle Container Cloud Service. Also note that the user specified in the registry definition must have sufficient privileges to write to the registry (see Creating a Docker Registry Definition).

You can use the same tag for multiple images. For example, you might want to push several different images to different repositories, but add the same ‘latest’ tag to each of them.

You can assign multiple tags to the same image. For example, you might add both a version number tag and the ‘latest’ tag to the same image.

A typical scenario might be:

  • The helloworld image is stored in the helloworld repository in the jsmith Docker registry. The most recent production version is version 5, and has the tags ‘v5’ and ‘latest’ in the repository.

  • You’ve already created a service in the Container Console based on version 5 of the helloworld image, and deployed it. When you defined the service, you specified jsmith/helloworld:latest as the image to use.

  • A developer pushes a new version of the helloworld image to the repository with the tag ‘v6’, which you want to test to assess whether it’s production quality.

  • You create a new service in the Container Console and specify jsmith/helloworld:v6 as the image to use. You deploy the service and test it.

  • The image passes all the tests, so you decide to make version 6 the new production version.

  • You add the ‘latest’ tag to the version 6 image in the Container Console and push the image to the jsmith/helloworld repository. The image that was previously tagged ‘latest’ is overwritten.

To push a Docker image to a Docker repository using the Oracle Container Cloud Service Container Console:

  1. On the Images page of the Container Console, click the name of the Docker image that you want to push.
  2. Click Add Tag to display the Tag Image window.
  3. In the Tag Image window:
    1. Enter the name of the Docker repository to which you want to push the image in the Repository field, in the format <username>/<repository_name>. For example, jsmith/helloworld.
      Note that the Docker repository you specify can be different to the repository that the image was pulled from originally. If the repository is in a different registry, a definition of that registry must already exist in Oracle Container Cloud Service. Also note that the user specified in the registry definition must have sufficient privileges to write to the registry (see Creating a Docker Registry Definition).
    2. Enter a descriptive tag to add to the image when it’s pushed to the Docker repository in the Tag field.
      The tag is up to you. For example, typical tags might be ‘latest’, ‘4.6.3 –20160823’, ‘7.5.2’.
    3. Click Create Tag.
    The new tag (which is the combination of the repository name and the description) is added to the image details.
  4. Click the Push button beside the new tag to push the image to the Docker repository you specified with the tag you entered.
    If an image with the same tag already exists in the repository, it’s overwritten. If the image didn’t previously exist in the target registry, a new repository is created and the image is pushed to it.