./categories/server
Docker Nginx 설치
이미지 pull·실행
docker pull nginx
docker run --name webserver -d -p 8080:80 nginx
docker ps
# http://localhost:8080
-d백그라운드-p 호스트:컨테이너(예: 8080→80)
중지/시작
docker stop webserver
docker start webserver
docker ps -a
볼륨 마운트 (html)
docker run -v /home/ubuntu/html:/usr/share/nginx/html --name webserver -d -p 8080:80 nginx
커스텀 nginx.conf + Dockerfile
nginx/
Dockerfile
conf/nginx.conf
conf/nginx.conf 예시:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
server_tokens off;
}
FROM nginx:latest
COPY conf/nginx.conf /etc/nginx/nginx.conf
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80
docker build --tag nginx-test:1.0 .
docker run -d -p 8080:80 nginx-test:1.0
관련 링크: https://app.notion.com/p/e860da48fcf741ee859a9012d7d3468e
./comments