MySQL Operator for Kubernetes Manual  /  Private Registries  /  Copy Image to Private Registry using Docker

6.3 Copy Image to Private Registry using Docker

Using air-gapped or sanctioned images to avoid pulling images from the internet is another use case and described here.

Note

MySQL Operator for Kubernetes requires these three container images to function: MySQL Operator for Kubernetes, MySQL Router, and MySQL Server.

  1. Choose the desired MySQL Operator for Kubernetes version. For example, latest is defined in helm/mysql-operator/Chart.yaml. For example, 9.1.0-2.2.2.

  2. Execute docker pull container-registry.oracle.com/mysql/community-operator:VERSION where VERSION is the desired MySQL Operator for Kubernetes version.

  3. Execute docker save container-registry.oracle.com/mysql/community-operator:VERSION -o mysql-operator.tar to export the container image where VERSION is the desired MySQL Operator for Kubernetes version.

  4. Copy mysql-operator.tar to a host with access to the private registry.

  5. Execute docker load -i mysql-operator.yaml to load the image into the local Docker cache on that host.

  6. Execute docker tag mysql/mysql-server:VERSION registry:port/repo/mysql-server:VERSION to retag the image as preparation for pushing to the private registry; adjust VERSION accordingly.

  7. Execute docker push registry:port/repo/mysql-server:VERSION to push the newly created tag to the private registry; adjust VERSION accordingly.

  8. If you won't need the image from the importing host cache, then you can delete it with docker rmi mysql/mysql-operator:VERSION registry:port/repo/mysql-server:VERSION. This removes it from the host but the registry itself won't be affected. Adjust VERSION accordingly.

Alternatively, you can use the following commands to pull and push in one command. Execute it on a host with Oracle Container Registry (OCR) access. If applicable, this host also needs access to the secure (bastion) host that can access the private registry. Modify the variable values to fit your needs. The command does not consume local space for a tarball but will stream the container image over SSH.

export BASTION_USER='k8s'
export BASTION_HOST='k8'
export REGISTRY="..." # for example 192.168.20.199:5000
export REPOSITORY="..." # for example mysql
export OPERATOR_VERSION=$(grep appVersion helm/mysql-operator/Chart.yaml | cut -d '"' -f2)
docker pull container-registry.oracle.com/mysql/community-operator:$OPERATOR_VERSION
docker save container-registry.oracle.com/mysql/community-operator:$OPERATOR_VERSION | \
    ssh $BASTION_USER@$BASTION_HOST \
         "docker load && \
          docker tag container-registry.oracle.com/mysql/community-operator:$OPERATOR_VERSION $REGISTRY/$REPOSITORY/mysql-operator:$OPERATOR_VERSION && \
          docker push $REGISTRY/$REPOSITORY/mysql-operator:$OPERATOR_VERSION && \
          docker rmi container-registry.oracle.com/mysql/community-operator:$OPERATOR_VERSION $REGISTRY/$REPOSITORY/mysql-operator:$OPERATOR_VERSION"
docker rmi container-registry.oracle.com/mysql/community-operator:$OPERATOR_VERSION