Home CentOS7 도커 nginx 실행하고 index.html 페이지 접속

도커 nginx 실행하고 index.html 페이지 접속

by maxblog
0 comment

도커에서 다운받은 nginx 이미지를 실행하고 index.html 파일을 만들어 띄워보려면
다음과 같은 순서데로 참고해서 한다.
이렇게 해보면 도커가 잘 이해가지 않을 때 좀더 이해할 수 있다.

Nginx 이미지 실행 (숫자는 nginx IMAGE ID)
docker run -it --name nginx_web -d -p 8000:80 88736fe82739


Centos7의 8000 포트로 도커의 80 포트를 연결한다.
이름은 nginx_web로 해준다.


도커 컨테이너 아이피 정보 보기 (숫자는 CONTAINER ID)
docker inspect 1f724da317d8


여기에서 아이피 주소를 확인하고 서버의 브라우저에서 접속페이지를 확인하면
nginx 초기 페이지를 확인 할 수 있다.


HTML 파일 만들기
vi index.html 

cat으로 index.html 소스 보기
cat index.html

도커 컨테이러 리스트를 다시 확인
docker ps

index.html 파일을 도커의 nginx 안으로 복사
(cp는 복사)(nginx_web는 앞에서 설정한 컨테이너 이름)
docker cp index.html nginx_web:/usr/share/nginx/html/index.html



이렇게 하고 서버의 브라우저에서 접속페이지를 확인한다.


Nginx 이미지 web02 이름으로 바꿔서 하나 더 띄우기 (숫자는 nginx IMAGE ID)
docker run -it --name nginx_web02 -d -p 8001:80 88736fe82739

좋아할만한 추천 글

Leave a Comment

Soledad is the Best Newspaper and Magazine WordPress Theme with tons of options and demos ready to import. This theme is perfect for blogs and excellent for online stores, news, magazine or review sites.

Buy Soledad now!

Edtior's Picks

Latest Articles

ⓒ 2023.  FUNCOM all rights reserved.