Skip to main content

Saving and using images with Container Registry

This document introduces the basic method for storing and using container images using the KakaoCloud Container Registry.

Basic information
  • Estimated time required: 20 minutes
  • User environment
    • Recommended operating system: MacOS
    • Region: kr-central-2
  • Prerequisites

Before you start

To smoothly proceed with the practice, certain programs need to be installed in your local environment. If the required programs are not installed, refer to the commands below for installation.

1. Install homebrew

Homebrew is a tool that helps with package installation and management in macOS environments. Enter the following command in the terminal to install it. After installation, you can verify it by running the brew help command.

Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. Install Git

Git is a version control system and an essential tool for this practice. Use Homebrew to install it as shown below. After installation, verify the Git version by entering the git --version command.

Install Git
brew install git

3. Install Docker

Docker is a tool that supports container-based virtualization and is necessary for setting up the practice environment. Use Homebrew's cask feature to install it.

Install Docker
brew install --cask docker
# Run the installed Docker Desktop
# If a privileged access prompt appears, click OK and enter your laptop user password.
docker help
# If the command outputs correctly, the installation is complete.

Getting started

Step 1. Create Container Registry

Container Registry를 이용하여 컨테이너 이미지를 보관하여 활용할 수 있습니다. You can use Container Registry to store and manage container images.

  1. In the KakaoCloud Console, go to the Container Registry menu to create a repository. Use the following settings to create the repository:

    CategoryRepository Settings
    VisibilityPrivate
    Repository Nametutorial
    Tag OverwriteEnabled
    Image ScanAutomatic
  2. Verify that the created repository is listed.

Step 2. Build docker image of example project

Install example project

  1. Create a directory for the example project and set it as the working directory.

    mkdir -p ~/Downloads/kakaocloud-library
    cd ~/Downloads/kakaocloud-library
  2. Then, install the example project using the following command.

    git clone -b kakaocloud-library https://github.com/kakaoenterprise/kakaocloud-tutorials
  3. Navigate to the example project directory as the working directory.

    cd kakaocloud-tutorials
  4. Verify the example project files.

    ls

Build example project

  1. Ensure that the Docker daemon is running to build the project. If an error message appears after the following command, start the Docker daemon using Docker Desktop. In MacOS, starting Docker Desktop also starts the Docker daemon automatically.

    Check Docker environment
    docker info
    Error
    Client:
    Version: ...
    Context: ...
    ...
    ...

    Server:
    ERROR: Cannot connect to the Docker daemon at unix:///Users/kakao_cloud/.docker/run/docker.sock. Is the docker daemon running?
    errors pretty printing info
  2. Build the server project for the linux/amd64 environment.

    docker build -t kakaocloud-library-server:latest --platform linux/amd64 -f ./server/deploy/Dockerfile ./server
  3. Tag the built server container image to align with the KakaoCloud environment.

    docker tag kakaocloud-library-server:latest {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-server:latest
    NameDescription
    PROJECT_NAMEContainer Registry를 생성한 카카오클라우드 콘솔의 프로젝트 이름
    REPOSITORY_NAMEContainer Registry에서 생성한 리포지토리의 이름
  4. Build the client project for the linux/amd64 environment.

    docker build -t kakaocloud-library-client:latest --platform linux/amd64 -f ./client/deploy/Dockerfile ./client
  5. Tag the built client container image to align with the KakaoCloud environment.

    docker tag kakaocloud-library-client:latest {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-client:latest
    NameInformation
    PROJECT_NAMEThe project name in KakaoCloud Console where the Container Registry was created
    REPOSITORY_NAMEThe name of the repository created in the Container Registry

Step 3. Upload example project images

Log in to Container Registry

  1. Log in to KakaoCloud Container Registry by entering your user information on the local machine.

    docker login {PROJECT_NAME}.kr-central-2.kcr.dev \
    --username {ACCESS_KEY} \
    --password {ACCESS_SECRET_KEY}
    NameInformation
    PROJECT_NAMEThe project name in KakaoCloud Console
    ACCESS_KEYAccess key
    ACCESS_SECRET_KEYSecret access key
  2. Verify the login result.

    # Result: Login Succeeded

Upload container images

  1. Upload the server container image.

    docker push {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-server:latest
    NameInformation
    PROJECT_NAMEThe project name in KakaoCloud Console where the Container Registry was created
    REPOSITORY_NAMEThe name of the repository created in the Container Registry
  2. Upload the client container image.

    docker push {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-client:latest
    NameInformation
    PROJECT_NAMEThe project name in KakaoCloud Console where the Container Registry was created
    REPOSITORY_NAMEThe name of the repository created in the Container Registry

Step 4. Verify the result

  1. Go to the KakaoCloud Console > Container Registry menu and access the tutorial repository you created.

  2. In the Images tab at the bottom, check if the uploaded images are listed.

    Image NameLabel
    kakaocloud-library-client-
    kakaocloud-library-server-
  3. The uploaded images can be downloaded using the command below. Enter it on your local machine to install the image.

    Server image
    docker pull {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-server:latest
    Client image
    docker pull {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-client:latest
    NameInformation
    PROJECT_NAMEThe project name in KakaoCloud Console where the Container Registry was created
    REPOSITORY_NAMEThe name of the repository created in the Container Registry
  4. Use the following command to verify if the image has been installed.

    Check Docker image list
    docker images