-
Rancher - nginx 쉘로 띄워보기ETC/MacOS,Rancher 2024. 7. 11. 10:45
custom.conf 생성
$ vi /Users/deokjoonkang/dev/opt/nginx/config/custom.conf server { listen 80; server_name example.com; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }
build-homepage.sh 작성
#!/bin/sh IMAGE_NAME=nginx IMAGE_VERSION=alpine CONTAINER_NAME=$IMAGE_NAME-$IMAGE_VERSION-homepage help() { if [ -z "$1" ]; then echo "사용법: $0 up|down|restart|logs|bash|build|rm|help" echo " $0 up : 컨테이너 시작" echo " $0 down : 컨테이너 종료" echo " $0 restart : 컨테이너 재시작" echo " $0 logs : 컨테이너 로그 열람 (tail -f)" echo " $0 bash : 컨테이너에 bash 접속" echo " $0 build : 컨테이너 빌드" echo " $0 rm : 컨테이너 제거" exit fi } up() { echo "" echo "############### [RUN] - nerdctl run ##### - STARTED" stop echo "" rm echo "" echo "##### [RUN] - nerdctl run $IMAGE_NAME-$IMAGE_VERSION ...options" nerdctl run -d \ -p 8091:80 \ -v /Users/deokjoonkang/dev/opt/nginx/config/custom.conf:/etc/nginx/conf.d/custom.conf:ro \ -v /Users/deokjoonkang/dev/projects/neoflat/gobang-homepage/src/resource:/usr/share/nginx/html:ro \ -e TZ=Asia/Seoul \ -e LC_ALL=C.UTF-8 \ --name "$CONTAINER_NAME" \ $IMAGE_NAME:$IMAGE_VERSION nerdctl ps -a echo "############### [RUN] - nerdctl run ##### - ENDED" echo "" } down() { echo "##### [STOP] - nerdctl stop $CONTAINER_NAME" nerdctl stop "$CONTAINER_NAME" } logs() { nerdctl logs -f $CONTAINER_NAME } bash() { #winpty docker exec -it $IMAGE_NAME bash #nerdctl exec -it $IMAGE_NAME bash nerdctl exec -ti --env COLUMNS=`tput cols` --env LINES=`tput lines` $CONTAINER_NAME bash } build() { nerdctl build -t $IMAGE_NAME:$IMAGE_VERSION -f ./Dockerfile . } rm() { echo "##### [RM] - nerdctl rm $CONTAINER_NAME" nerdctl rm "$CONTAINER_NAME" } main() { local cmd=${1:-''} case "${cmd}" in "up") up ;; "down") down ;; "restart") down up ;; "logs") logs ;; "bash") bash ;; "build") build ;; "rm") rm ;; "help"|*) help exit ;; esac } main ${@}
실행 권한주기
$ chmod +x ./build-mariaDB.sh
실행 및 확인
deokjoonkang@gangdeogjun-ui-MacBookPro nginx % ./build-homepage.sh up ############### [RUN] - nerdctl run ##### - STARTED ./build-homepage.sh: line 24: stop: command not found ##### [RM] - nerdctl rm nginx-alpine-homepage FATA[0000] 1 errors: no such container: nginx-alpine-homepage Error: exit status 1 ##### [RUN] - nerdctl run nginx-alpine ...options cdd9873d0a6ec2fb544964f28e753296b7d1f2dbb66e545a15c9ed13aeaa3e95 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 55d00ed36bce docker.io/library/mariadb:10.6.8 "docker-entrypoint.s…" 4 months ago Created 0.0.0.0:3306->3306/tcp mariadb-10.6.8 c2f6267ac31b docker.io/library/thumbor:7.7.4 "/bin/sh -c bash /th…" About an hour ago Up 0.0.0.0:8888->8888/tcp, 0.0.0.0:8889->8889/tcp thumbor-7.7.4 cdd9873d0a6e docker.io/library/nginx:alpine "/docker-entrypoint.…" Less than a second ago Up 0.0.0.0:8091->80/tcp nginx-alpine-homepage ############### [RUN] - nerdctl run ##### - ENDED
'ETC > MacOS,Rancher' 카테고리의 다른 글
맥에서 방해금지 모드 설정 (0) 2025.01.17 Rancher/Docker/oracle 서버 실행하기 (4) 2024.11.09 Mac에서 Python으로 된 thumbor Rancher로 기동 (0) 2024.04.12 Mac crontab 설정 (0) 2024.04.08 Rancher - react build html nginx로 띄워보기 (0) 2024.03.15