Saving and using images with Container Registry
This document introduces the basic method for storing and using container images using the KakaoCloud Container Registry.
- 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.
/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.
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.
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.
-
In the KakaoCloud Console, go to the Container Registry menu to create a repository. Use the following settings to create the repository:
Category Repository Settings Visibility Private Repository Name tutorial Tag Overwrite Enabled Image Scan Automatic -
Verify that the created repository is listed.
Step 2. Build docker image of example project
Install example project
-
Create a directory for the example project and set it as the working directory.
mkdir -p ~/Downloads/kakaocloud-library
cd ~/Downloads/kakaocloud-library -
Then, install the example project using the following command.
git clone -b kakaocloud-library https://github.com/kakaoenterprise/kakaocloud-tutorials
-
Navigate to the example project directory as the working directory.
cd kakaocloud-tutorials
-
Verify the example project files.
ls
Build example project
-
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
. InMacOS
, startingDocker Desktop
also starts the Docker daemon automatically.Check Docker environmentdocker info
ErrorClient:
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 -
Build the server project for the
linux/amd64
environment.docker build -t kakaocloud-library-server:latest --platform linux/amd64 -f ./server/deploy/Dockerfile ./server
-
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
Name Description PROJECT_NAME Container Registry를 생성한 카카오클라우드 콘솔의 프로젝트 이름 REPOSITORY_NAME Container Registry에서 생성한 리포지토리의 이름 -
Build the client project for the
linux/amd64
environment.docker build -t kakaocloud-library-client:latest --platform linux/amd64 -f ./client/deploy/Dockerfile ./client
-
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
Name Information PROJECT_NAME The project name in KakaoCloud Console where the Container Registry was created REPOSITORY_NAME The name of the repository created in the Container Registry
Step 3. Upload example project images
Log in to Container Registry
-
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}Name Information PROJECT_NAME The project name in KakaoCloud Console ACCESS_KEY Access key ACCESS_SECRET_KEY Secret access key -
Verify the login result.
# Result: Login Succeeded
Upload container images
-
Upload the server container image.
docker push {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-server:latest
Name Information PROJECT_NAME The project name in KakaoCloud Console where the Container Registry was created REPOSITORY_NAME The name of the repository created in the Container Registry -
Upload the client container image.
docker push {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-client:latest
Name Information PROJECT_NAME The project name in KakaoCloud Console where the Container Registry was created REPOSITORY_NAME The name of the repository created in the Container Registry
Step 4. Verify the result
-
Go to the KakaoCloud Console > Container Registry menu and access the
tutorial
repository you created. -
In the Images tab at the bottom, check if the uploaded images are listed.
Image Name Label kakaocloud-library-client - kakaocloud-library-server - -
The uploaded images can be downloaded using the command below. Enter it on your local machine to install the image.
Server imagedocker pull {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-server:latest
Client imagedocker pull {PROJECT_NAME}.kr-central-2.kcr.dev/{REPOSITORY_NAME}/kakaocloud-library-client:latest
Name Information PROJECT_NAME The project name in KakaoCloud Console where the Container Registry was created REPOSITORY_NAME The name of the repository created in the Container Registry -
Use the following command to verify if the image has been installed.
Check Docker image listdocker images