brunch
매거진 AWS Cloud

4탄-도커 파일 만들고 이미지 업로드-3/4

by Master Seo

<1> 도커 파일로 이미지 만들기

<2> ECR에 이미지 올리기



<1> 도커 파일로 이미지 만들기

10 ecr.jfif


참고

https://brunch.co.kr/@topasvga/1363



1

vi Dockerfile


ec2-user:~/environment $ more Dockerfile

FROM ubuntu:18.04

# Install dependencies

RUN apt-get update && \

apt-get -y install apache2

# Install apache and write hello world message

RUN echo 'Hello World!' > /var/www/html/index.html

# Configure apache

RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh && \

echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh && \

echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.sh && \

echo '/usr/sbin/apache2 -D FOREGROUND' >> /root/run_apache.sh && \

chmod 755 /root/run_apache.sh

EXPOSE 80

CMD /root/run_apache.sh



2

docker build -t hello-world .



<2> ECR에 이미지 올리기


1

seoul region


서울 리전

aws ecr create-repository --repository-name hello-repository4


docker tag hello-world 451032684083.dkr.ecr.ap-northeast-2.amazonaws.com/hello-repository4


aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 451032684083.dkr.ecr.ap-northeast-2.amazonaws.com


docker push 451032684083.dkr.ecr.ap-northeast-2.amazonaws.com/hello-repository4



2

us-east2


aws ecr create-repository --repository-name hello-repository3 --region us-east-2


docker tag hello-world 451032684083.dkr.ecr.us-east-2.amazonaws.com/hello-repository3


aws ecr get-login-password --region us-east-2 | docker login --username AWS --password-stdin 451032684083.dkr.ecr.us-east-2.amazonaws.com


docker push 451032684083.dkr.ecr.us-east-2.amazonaws.com/hello-repository3






100 ok.png



다음은

https://brunch.co.kr/@topasvga/2089



감사합니다.


keyword
매거진의 이전글4탄-ECS을 위한 Cloud9개발환경 구성-2/4