이번 포스팅은
이다.
인스턴스 생성 후 실행시킨다. 인스턴스 만드는법, Putty 접속법 등 자세한 건 이 포스팅에서x
login as: ubuntu
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 5.4.0-1069-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Mon Apr 4 03:02:58 UTC 2022
System load: 0.06 Processes: 106
Usage of /: 40.6% of 7.69GB Users logged in: 0
이렇게 뜹니다
docker에서, 특정 프로세스를 실행시키기 위해 준비된 파일과 환경설정들 (즉, 컨테이너) 그 각각을 image라고 한다.
image들은 DockerHub (깃헙과 유사) 이용해 버전 관리, 배포 (push, pull)가 가능하다.
docker images
결과
ubuntu@ip-172-31-**-***:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
00mari/firstweb latest 8fca3dc46f69 4 days ago 276MB
ubuntu latest ff0fea8310f3 2 weeks ago 72.8MB
hello-world latest feb5d9fea6a5 6 months ago 13.3kB
결과가 나온다
이미 docker 허브에 00mari/firstweb 만들어서 연동시켰던 image가 보인다.
docker run -it -d 이미지이름
docker ps
run 시에 DockerHub에 연동된 게 있다면 자동으로 pull 수행된다.
docker ps 하면 CONTANER ID 아래에 임의의 문자열 나옴, 혹은 NAMES 밑에 영단어 2개 조합된 이름 나온다. 둘 중 하나를 복사한다.
실습에서는 ubuntu 접속
docker exec -it <container id> <program in the container>
containter id는 아이디 혹은 name으로 대체 가능, program은 일단 bash 입력
성공 시 bash 창 명령어 입력 좌측 문자열이 바뀐다 (컨테이너 진입)
apt-get update
apt-get install -y apache2
설치 확인
까는 김에 vim도 설치
apt-get install -y vim
cd /var/www/html
vim 1.html
html 파일 입력
<h1>
My website
</h1>
<h2 style="color:seaGreen">
So nice!!
</h2>
docker ps
docker commit <containerID> 00mari/secondweb
sha256: 하고 뭐라고 뜸
해쉬된 결과물임
docker exec -it <Container id> bash
service apache2 status
not running
service apache2 start
Could not reliably determine the server's fully qualified domain name
도메인 네임도 없는데 시작해서 뭐하냐는 경고
docker run -it -p 81:80 -d 00mari/secondweb
포트포워딩 설정한것.
퍼블릭 ip주소 복붙 후
주소/81:80
이렇게 하면 접속 가능
사실 그전에 인스턴스 보안 설정 - 보안그룹규칙ID- 인바운드 룰- 81번 포트 열어줘야됨