1 분 소요


자주 사용하는 쿠버네티스 명령을 정리하고 있습니다.


Kubectl

kubectl 전체 리소스 검색

  $ kubectl get all  




Docker Registry

CodeBox/Kubernetes

local registry



로컬 도커 이미지 사용하기

  • 로컬 레지스트리 설정하기
    $ docker run -d -p 5000:5000 --restart=always --name registry registry:latest
    

여기에서는 로컬 호스트의 5000 포트에 레지스트리를 실행합니다.

  • Dockerfile 이미지 빌드 및 태깅하기
    # Dockerfile 경로로 이동
    $ docker build -t localhost:5000/{Image Name} .
    $ docker push localhost:5000/{Image Name}
    
  • 이미지 가져오기 정책(Image Pull Policy) 설정하기
    apiVersion: v1
    kind: Pod
    metadata:
      name: my-pod
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: localhost:5000/{Image Name}
          imagePullPolicy: Never
    


관련자료



로컬 레지스트리의 저장소 리스트하기

로컬 레지스트리(localhost:5000)의

http://localhost:5000/v2/_catalog


관련자료



도커 저장소 삭제하기

저장소 리스팅하기:

$ curl -X GET http://localhost:5000/v2/_catalog
  {"repositories":["{Repository}"]}

태그 리스팅하기:

$ curl -X GET http://localhost:5000/v2/{Repository}/tags/list
  {"name":"{Repository}","tags":["0.5"]}

blob 확인하기:

$ curl -i -X GET http://localhost:5000/v2/{Repository}/manifests/{Tags}
HTTP/1.1 200 OK
Content-Length: 4262
Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
Docker-Content-Digest: sha256:2c91f8e2886b714e3a865318551dd6b59925bf4f4fb418fbfdf3704fbef50902
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:2c91f8e2886b714e3a865318551dd6b59925bf4f4fb418fbfdf3704fbef50902"
X-Content-Type-Options: nosniff
Date: Thu, 27 May 2021 03:18:05 GMT

{
   "schemaVersion": 1,
   "name": "com2us.com/agones-sample/spy",
   "tag": "0.5",
   "architecture": "amd64",
   "fsLayers": [
      {
         "blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
      },
      ...
   ],
   "history": [
     ...
   ],
   "signatures": [
     ...
   ]
}

blob 으로 삭제하기:

$ curl -i -X DELETE http://localhost:5000/v2/com2us.com/agones-sample/spy/manifests/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4  
  HTTP/1.1 202 Accepted

만약, 다음과 같은 에러가 발생한다면,

{"errors":[{"code":"UNSUPPORTED","message":"The operation is unsupported."}]}


관련자료




Docker

Dockerfile 상위 디렉토리에서 파일을 COPY 하는 방법

먼저 COPY 명령으로 현재 디렉토리(./) 를 복사한다:

FROM  node:alpine
WORKDIR /app
COPY ./ ./
RUN npm install
EXPOSE 80
ENTRYPOINT [ "npm", "start" ]

docker build 명령을 상위 디렉토리에서 실행한다:

~/Code/node-app/docker
$ cd ..

~/Code/node-app
$ docker build -t node-app -f docker/Dockerfile .
Sending build context to Docker daemon  263.7MB
...
Successfully built d296bf765369
Successfully tagged node-app:latest

댓글남기기