Artifact Registry에 Apt 패키지 저장
이 빠른 시작에서는 비공개 Artifact Registry Apt 저장소를 설정하고, 저장소에 Debian 패키지를 추가하고, Debian 기반 운영체제를 실행하는 Compute Engine VM에 패키지를 설치하는 방법을 보여줍니다.
Cloud Shell을 사용하여 이 빠른 시작의 단계를 수행하거나 이 빠른 시작에서 만드는 VM의 셸에서 단계를 수행합니다.
Debian 패키지 관리에 관한 자세한 내용은 Debian 패키지로 작업을 참조하세요.
시작하기 전에
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry API.
Cloud Shell 실행
Cloud Shell에는 Google Cloud CLI가 사전 설치되어 있습니다. gcloud CLI는 Google Cloud의 기본 명령줄 인터페이스를 제공합니다.
Cloud Shell 시작:
Google Cloud 콘솔로 이동합니다.
Google Cloud 콘솔 툴바에서 Cloud Shell 활성화를 클릭합니다.

Console 하단의 프레임에서 Cloud Shell 세션이 열립니다.
이 셸을 사용하여 gcloud 명령어를 실행하여 VM 및 저장소를 만듭니다.
저장소 만들기
아티팩트에 대한 저장소를 만듭니다.
저장소를 만듭니다.
콘솔
Google Cloud 콘솔에서 저장소 페이지를 엽니다.
저장소 만들기를 클릭합니다.
quickstart-apt-repo를 저장소 이름으로 지정합니다.형식으로 Apt를 선택합니다.
위치 유형에서 리전을 선택한 후
us-central1위치를 선택합니다.만들기를 클릭합니다.
저장소가 저장소 목록에 추가됩니다.
gcloud
Cloud Shell에서 다음 명령어를 실행하여
us-central1위치에 있는quickstart-apt-repo라는 현재 프로젝트의 새로운 Apt 저장소를 만듭니다.gcloud artifacts repositories create quickstart-apt-repo \ --repository-format=apt \ --location=us-central1 \ --description="Apt repository"다음 명령어를 실행하여 저장소가 생성되었는지 확인합니다.
gcloud artifacts repositories list
이제 저장소에 패키지를 추가할 수 있습니다.
저장소에 패키지 추가
Google Cloud CLI를 사용하여 저장소에 패키지를 업로드하거나 Cloud Storage에 저장된 패키지를 가져올 수 있습니다. Cloud Build를 사용하여 패키지를 빌드하는 경우 빌드는 패키지를 가져올 수 있도록 Cloud Storage에 저장할 수 있습니다.
이 빠른 시작에서는 gcloud artifacts apt
upload 명령어를 사용하여 샘플 파일을 업로드합니다.
Cloud Shell에서 다음 명령어를 사용하여 Apt 빠른 참조 시트를 다운로드합니다.
apt download apt-dpkg-refApt는 구성된 Apt 저장소에서 사용 가능한 최신 버전의 패키지를 다운로드합니다.
Get:1 http://deb.debian.org/debian buster/main amd64 apt-dpkg-ref all 5.3.1+nmu2 [113 kB] Fetched 113 kB in 0s (428 kB/s)ls를 실행하여 Apt 빠른 참조 시트의 파일 이름을 가져옵니다. 파일 이름은apt-dpkg-ref_5.3.1+nmu2_all.deb와 유사한 형식입니다.gcloud명령어를 단순화하려면 기본 저장소를quickstart-apt-repo로 설정하고 기본 위치를us-central1로 설정합니다. 이 값을 설정하면 저장소나 위치가 필요한gcloud명령어에 값을 지정할 필요가 없습니다.저장소를 설정하려면 다음 명령어를 실행하세요.
gcloud config set artifacts/repository quickstart-apt-repo위치를 설정하려면 다음 명령어를 실행하세요.
gcloud config set artifacts/location us-central1이러한 명령어에 대한 자세한 내용은 gcloud config set 문서를 참조하세요.
gcloud artifacts apt upload를 실행하여 저장소에 패키지를 업로드합니다.gcloud artifacts apt upload quickstart-apt-repo \ --source=FILE_NAMEFILE_NAME을 Apt 빠른 참조 시트의 경로로 바꿉니다.
저장소에서 패키지 보기
패키지가 저장소에 추가되었는지 확인합니다.
콘솔
Google Cloud 콘솔에서 저장소 페이지를 엽니다.
저장소 목록에서 quickstart-apt-repo 저장소를 클릭합니다.
패키지 페이지에 저장소의 패키지가 나열됩니다.
gcloud
quickstart-apt-repo 저장소에 패키지를 나열하려면 다음 명령어를 실행합니다.
gcloud artifacts packages list
quickstart-apt-repo에서 패키지 버전을 보려면 다음 명령어를 실행합니다.
gcloud artifacts versions list --package=apt-dpkg-ref
VM 만들기
샘플 패키지를 설치할 새 Compute Engine VM을 만듭니다.
Cloud Shell에서 다음 명령어를 실행하여 quickstart-apt-vm이라는 VM 인스턴스를 만듭니다.
gcloud compute instances create quickstart-apt-vm \
--image-family=debian-10 \
--image-project=debian-cloud \
--scopes=cloud-platform
기본적으로 VM에는 저장소 작업에 필요한 액세스 범위가 없습니다. --scopes 플래그는 VM의 액세스 범위를 cloud-platform으로 설정합니다.
패키지 관리자 구성
VM에 패키지를 설치하려면 패키지 저장소를 정의하는 Apt 구성 파일에 만든 저장소를 추가합니다.
VM 인스턴스 페이지로 이동합니다.
VM이 있는 행에서 SSH를 클릭합니다. VM의 터미널 세션이 있는 새 창이 열립니다.
gcloud init을 실행하여 VM에서 Google Cloud CLI를 초기화합니다.Apt 업데이트:
sudo apt updateApt가 인증을 수행할 수 있도록 VM에 Apt 사용자 인증 정보 도우미를 설치합니다.
sudo apt install apt-transport-artifact-registry다음 명령어를 사용하여 Artifact Registry 패키지에 액세스하도록 VM을 구성합니다.
echo 'deb ar+https://us-central1-apt.pkg.dev/projects/PROJECT quickstart-apt-repo main' | sudo tee -a /etc/apt/sources.list.d/artifact-registry.listPROJECT를 Google Cloud 프로젝트 ID로 바꿉니다.
패키지 설치
저장소에 추가한 패키지를 설치합니다.
사용 가능한 패키지 목록을 업데이트합니다.
sudo apt update저장소에 패키지를 설치합니다.
sudo apt install apt-dpkg-ref/quickstart-apt-repo반환된 설치 정보는 다음 예시와 같이 표시됩니다.
Reading package lists... Done Building dependency tree Reading state information... Done Selected version '5.3.1+nmu2' (Debian:10.7/stable, namespaces/my-repo/repositories/quickstart-apt-repo:quickstart -apt-repo [all]) for 'apt-dpkg-ref' The following NEW packages will be installed: apt-dpkg-ref 0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded. Need to get 113 kB of archives. After this operation, 128 kB of additional disk space will be used. Get:1 http://deb.debian.org/debian buster/main amd64 apt-dpkg-ref all 5.3.1+nmu2 [113 kB] Fetched 113 kB in 0s (693 kB/s) Selecting previously unselected package apt-dpkg-ref. (Reading database ... 39506 files and directories currently installed.) Preparing to unpack .../apt-dpkg-ref_5.3.1+nmu2_all.deb ... Unpacking apt-dpkg-ref (5.3.1+nmu2) ... Setting up apt-dpkg-ref (5.3.1+nmu2) ...
삭제
이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.
저장소를 삭제하기 전에, 보관할 패키지를 다른 위치에서 사용할 수 있는지 확인합니다.
저장소를 삭제하려면 다음 안내를 따르세요.
콘솔
Google Cloud 콘솔에서 저장소 페이지를 엽니다.
저장소 목록에서 quickstart-apt-repo 저장소를 선택합니다.
삭제를 클릭합니다.
gcloud
quickstart-apt-repo저장소를 삭제하려면 다음 명령어를 실행합니다.gcloud artifacts repositories delete quickstart-apt-repo활성
gcloud구성에 지정한 기본 저장소와 위치 설정을 삭제하려면 다음 명령어를 실행합니다.gcloud config unset artifacts/repository gcloud config unset artifacts/location
생성된 VM을 삭제하려면 다음 명령어를 실행하세요.
gcloud compute instances delete quickstart-apt-vm
다음 단계
- Deb 패키지 작업에 대해 알아보기
- DevOps 관련 리소스를 읽고 연구 프로그램을 살펴보기