[NGINX] 엔진엑스 도커에 설치 및 상태 확인하기
- 운영체제 / 엔진엑스
- 2022. 8. 6.
▼ 우선 도커 명령어를 사용해서 다음과 같이 NginX 이미지를 다운로드 합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker pull nginx |
▼ 이미지를 다운로드 받았다면 다음과 같이 새로운 컨테이너를 생성합니다.
--name : 실행할 컨테이너의 이름을 입력합니다.
-d : 백그라운드로 실행합니다.
-p : 포트를 설정합니다. (내부는 80으로 지정하고 외부는 8080으로 지정합니다.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker container run --name webserver -d -p 8080:80 nginx |
▼ 컨테이너 상태를 확인하기 위해서 컨테이너 내부로 들어갑니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker exec -it nginx /bin/bash |
▼ nginx -v 명령을 통해서 버전을 확입합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nginx -v | |
nginx version: nginx/1.23.1 |
▼ ps 명령을 사용해서 nginx의 상태를 확인해야 하지만 해당 명령이 없을 경우 apt-get 명령을 통해서 procps 를 설치합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ apt-get update | |
$ apt-get install -y procps |
▼ procps 가 설치되었다면 다음과 같이 ps 명령을 이용해서 nginx의 상태를 확인합니다.
grep 명령으로 프로세스 목록에서 nginx를 포함하는 총 5개의 프로세스를 확인할 수 있습니다. master와 worker로 구성되어 있으며 이는 시스템에 따라서 갯수가 다를 수 있습니다. 하지만 최소 1개의 마스터와 1개의 워커로 구성됩니다. 마스터의 경우 root 권한으로 실행됩니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ps -ef | grep nginx | |
root 1 0 0 09:46 pts/0 00:00:00 nginx: master process nginx -g daemon off; | |
nginx 31 1 0 09:46 pts/0 00:00:00 nginx: worker process | |
nginx 32 1 0 09:46 pts/0 00:00:00 nginx: worker process | |
nginx 33 1 0 09:46 pts/0 00:00:00 nginx: worker process | |
nginx 34 1 0 09:46 pts/0 00:00:00 nginx: worker process | |
root 401 35 0 10:01 pts/1 00:00:00 grep nginx |
▼ curl 명령어를 통해서 nginx가 정상동작 하는지 확인합니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl localhost:8080 |