상세 컨텐츠

본문 제목

[Ncloud] Script 적용 (Docker 설치 & HTTP 실행)

IT/Ncloud

by o_zeew 2022. 6. 4. 22:04

본문

문제

 

  * 서버 생성 시 스크립트를 지정하면 스크립트의 내용이 자동 실행 *


1. 스크립트 작성

#! /bin/bash
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
docker pull httpd
cat > index.html << EOF
<html>
<body>
<h1>MAIN-WEBSERVER</h1>
</body>
</html>
EOF
docker run -itd --name h1 -p 8080:80 httpd
docker cp index.html h1:/usr/local/apache2/htdocs/index.html

 

2. Ncloud 스크립트 생성

Script 생성
작성한 스크립트 붙여넣기
스크립트 생성 완료

 

3. 서버 생성 

서버 생성
Script 선택

 

4. 외부 접속을 위한 공인 IP 생성

공인 IP 신청

 

5. 서버에 공인 IP 할당

운영중인 서버

 

6. Script 적용 확인

웹 페이지 접속 가능

관련글 더보기