Photon OS 에서 NGINX 및 NGINX Plus 실행
이 포스트은 Photon OS 에서 Docker 컨테이너에서 NGINX 오픈소스 및 NGINX Plus 를 실행하는 것이 얼마나 간단한지를 보여줍니다. Photon OS를 설치하는 방법을 설명한 후, NGINX와 NGINX Plus에 대한 별도의 지침을 제공합니다.
Photon OS는 컨테이너를 실행하도록 특별히 설계된 VMware의 새로운 경량 Linux 배포판입니다.
Photon OS는 Docker, rkt 및 Pivotal Garden을 포함한 여러 컨테이너 사양을 지원합니다. Photon OS의 목표 중 하나는 VMware vSphere에서 실행할 때 높은 성능을 제공하는 것입니다. 효율적인 라이프사이클 관리를 위한 새로운 yum 호환 패키지 매니저 인 tdnf가 함께 제공됩니다. Photon OS는 또한 rpm-OSTree를 지원하여 모든 인스턴스에서 파일 시스템 트리의 버전화된 원자적 업그레이드를 수행하고 트리 내 패키지 상태를 제어하기 위한 rpm 기반 패키지 매니저를 지원합니다.
목차
1. Photon OS 설치
2. Photon OS 로 NGINX 실행
3. Photon OS로 NGINX Plus 실행
4. 요약
1. Photon OS 설치
Photon OS를 사용하려면 가상화 소프트웨어에 OVA 파일을 가져오거나 ISO 이미지에서 Photon OS를 설치하여 시작할 수 있습니다. VMWare는 또한 Amazon Web Services, Google Cloud Environment 및 Microsoft Azure에 대한 실험적인 네이티브 이미지도 제공합니다. 자세한 설치 지침은 위키를 방문하십시오.
Note: 기본적으로 Docker 데몬은 부팅 시 자동으로 시작되지 않습니다. 데몬을 시작하려면 다음 명령을 실행하십시오.
# systemctl start docker
2. Photon OS 로 NGINX 실행
인스턴스가 실행되면 Docker 컨테이너에서 NGINX를 시작할 수 있습니다. (NGINX Plus의 경우 다음 섹션을 참조하십시오.)
다음 명령을 실행합니다.
# docker run --name mynginx -p 8080:80 -d nginx
우리는 컨테이너 내부의 포트 80을 Photon OS 호스트의 포트 8080에 매핑합니다. NGINX 이미지가 Docker Hub에서 가져온 후에 NGINX 컨테이너가 시작됩니다.
이제 curl 명령을 실행하여 NGINX가 실제로 실행 중인지 확인하고 기본 NGINX 환영 페이지의 텍스트를 확인해 보겠습니다.
# curl localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
3. Photon OS로 NGINX Plus 실행
NGINX와 비교하여 NGINX Plus를 Photon OS Docker 컨테이너에서 실행하는 경우 추가 단계가 필요합니다. Docker Hub에서 사용할 수 없는 NGINX Plus 컨테이너 이미지를 빌드해야 합니다.
다음은 Ubuntu 14.04를 기본 이미지로 사용하여 이미지를 빌드하기 위한 Dockerfile입니다. NGINX Plus 구독 또는 평가판에서 제공하는 nginx-repo.crt 및 nginx-repo.key 파일을 Dockerfile과 동일한 폴더에 넣어야 합니다.
FROM ubuntu:14.04
MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com"
# Set the debconf frontend to Noninteractive
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update && apt-get install -y -q wget apt-transport-https ca-certificates
# Download certificate and key from the customer portal (https://cs.nginx.com)
# and copy to the build context
ADD nginx-repo.crt /etc/ssl/nginx/
ADD nginx-repo.key /etc/ssl/nginx/
# Get other files required for installation
RUN wget -q -O - https://nginx.org/keys/nginx_signing.key | apt-key add -
RUN wget -q -O /etc/apt/apt.conf.d/90nginx https://cs.nginx.com/static/files/90nginx
RUN printf "deb https://plus-pkgs.nginx.com/ubuntu `lsb_release -cs` nginx-plusn" > /etc/apt/sources.list.d/nginx-plus.list
# Install NGINX Plus
RUN apt-get update && apt-get install -y nginx-plus
# forward request logs to Docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
이미지를 빌드하려면 다음 명령어를 실행합니다.
# docker build -t nginxplus
docker images
명령어를 실행하여 이미지가 성공적으로 빌드되었는지 확인하세요 (샘플 출력의 첫 번째 줄에 표시됩니다).
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
nginxplus latest f0dfff373cf3 37 seconds ago 229 MB
nginx latest 5c82215b03d1 6 days ago 132.8 MB
ubuntu 14.04 a005e6b7dd01 8 days ago 188.3 MB
이미지를 사용하여 컨테이너를 시작하려면 다음 명령어를 실행합니다.
# docker run --name mynginxlplus -p 80:80 -d nginxplus
NGINX와 NGINX Plus를 Docker 컨테이너에서 실행하는 방법에 대한 자세한 지침은 “자습서-Docker와 함께 NGINX 및 NGINX Plus 배포” 포스트를 참조하세요. 이 포스트에서는 NGINX Plus Docker 이미지를 빌드하는 방법, 콘텐츠를 관리하는 방법, NGINX 구성 파일 및 로깅을 설정하는 방법 등을 자세히 설명합니다.
4. 요약
Photon OS 는 VMware vSphere에서 고성능을 위해 설계된 가벼운 Linux 컨테이너 호스트입니다. NGINX와 NGINX Plus는 Docker 컨테이너에서 쉽게 배포하여 Photon OS 환경에서 앱을 제공할 수 있습니다.
NGINX Plus로 시작하려면 지금 무료 30일 체험을 신청하세요.
아래 뉴스레터를 구독하고 NGINX와 NGINX STORE의 최신 정보들을 빠르게 전달 받아보세요.