aws에 ecr 검색 후 Repositories에서 생성
사용자 -> 사용자 추가
권한의 경우 오류 해결을 위해 추가해보았는데 추가 안해도 제대로 작동할 수도 있음
AmazonEC2ContainerRegistryFullAccess,
AmazonEC2ContainerServiceforEC2Role
보안 자격 증명에서 액세스 키 생성
-> access key, secret access key 생성(csv로 저장 가능)
https://docs.aws.amazon.com/ko_kr/cli/latest/userguide/getting-started-install.html 공식 문서
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install
$ aws --version // version check
$ aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]: json
iam에서 얻은 access key, secret access key를 사용,
region name은 본인 인스턴스 지역. ecr - 푸쉬 명령 보기에서 확인
output format은 일단 json으로 설정함
ecr -> repositories -> image -> 푸쉬 명령 보기
첫번째 명령을 사용하면 정상적으로 로그인 됨
WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-app v1 4a021aa4a38d 20 hours ago 408MB
my-ubuntu v1 7ebf1377db43 22 hours ago 72.8MB
nodejs-server latest 1c6460fadeaa 23 hours ago 916MB
skybluelee/my-nginx v1.0.0 1c6460fadeaa 23 hours ago 916MB
nginx latest 6efc10a0510f 5 days ago 142MB
ubuntu focal 1c5c8d0b973a 5 weeks ago 72.8MB
$ docker tag nginx:latest <aws 주소 - 푸쉬 명령 보기 에서 확인>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-app v1 4a021aa4a38d 20 hours ago 408MB
my-ubuntu v1 7ebf1377db43 22 hours ago 72.8MB
nodejs-server latest 1c6460fadeaa 23 hours ago 916MB
skybluelee/my-nginx v1.0.0 1c6460fadeaa 23 hours ago 916MB
<aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx v1.0.0 6efc10a0510f 5 days ago 142MB
nginx latest 6efc10a0510f 5 days ago 142MB
ubuntu focal 1c5c8d0b973a 5 weeks ago 72.8MB
새로운 image 생성 확인
$ docker push <aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
The push refers to repository [<aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx]
9d907f11dc74: Pushed
79974a1a12aa: Pushed
f12d4345b7f3: Pushed
935b5bd454e1: Pushed
fb6d57d46ad5: Pushed
ed7b0ef3bf5b: Pushed
v1.0.0: digest: sha256:f2fee5c7194cbbfb9d2711fa5de094c797a42a51aa42b0c8ee8ca31547c872b1 size: 1570
$ docker rmi <aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
Untagged: <aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
Untagged: <aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx@sha256:f2fee5c7194cbbfb9d2711fa5de094c797a42a51aa42b0c8ee8ca31547c872b1
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-app v1 4a021aa4a38d 20 hours ago 408MB
my-ubuntu v1 7ebf1377db43 22 hours ago 72.8MB
nodejs-server latest 1c6460fadeaa 23 hours ago 916MB
skybluelee/my-nginx v1.0.0 1c6460fadeaa 23 hours ago 916MB
nginx latest 6efc10a0510f 5 days ago 142MB
ubuntu focal 1c5c8d0b973a 5 weeks ago 72.8MB
$ docker pull <aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
v1.0.0: Pulling from my-nginx
Digest: sha256:f2fee5c7194cbbfb9d2711fa5de094c797a42a51aa42b0c8ee8ca31547c872b1
Status: Downloaded newer image for <aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
<aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx:v1.0.0
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-app v1 4a021aa4a38d 20 hours ago 408MB
my-ubuntu v1 7ebf1377db43 22 hours ago 72.8MB
nodejs-server latest 1c6460fadeaa 23 hours ago 916MB
skybluelee/my-nginx v1.0.0 1c6460fadeaa 23 hours ago 916MB
<aws 주소>.dkr.ecr.ap-northeast-1.amazonaws.com/my-nginx v1.0.0 6efc10a0510f 5 days ago 142MB
nginx latest 6efc10a0510f 5 days ago 142MB
ubuntu focal 1c5c8d0b973a 5 weeks ago 72.8MB
제대로 다운로드 되는 것을 확인