Docker Container - nginx service
본문
Launching a Container
Accessing the Container
Container Management
Publishing the Container
Image Management
Using Docker Hub
*** 실습 ***
web 컨테이너 시작
$ docker run --name web -dt nginx
a6a913ac9e2a4c9ac578a0b436f4f82086ee26ae309518b9c6509bc64a93aac6
web 컨테이너 확인
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a6a913ac9e2a nginx "/docker-entrypoint.…" 44 seconds ago Up 43 seconds 80/tcp web
web 컨테이너의 nginx 설정 파일 default.conf 과 html 디렉토리 파일 확인
$ cat default.conf
server {
listen 80;
listen [::]:80;
server_name localhost;
root /var/www/html/;
}
$ ls html/
index.html
web 컨테이너의 nginx 설정 파일 default.conf 과 html 디렉토리 복사
$ docker exec web mkdir /var/www
$ docker cp default.conf web:/etc/nginx/conf.d/default.conf
$ docker cp html web:/var/www/
$ docker exec web ls /var/www/html
index.html
$ docker exec web chown -R nginx:nginx /var/www/html
nginx서비스 reload
$ docker exec web nginx -s reload
2022/04/07 22:59:08 [notice] 97#97: signal process started
web 컨테이너 IP 확인
$ docker inspect web | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.5",
"IPAddress": "172.17.0.5",
docker commit
$ docker commit web web-image
sha256:139788b1141bc9d9a89301d1ea8a584df1614174be8eda72ffbf820ce72ac987
$ docker run -dt --name web10 -p 80:80 web-image
b292fd7387f71a999e3182cc5fa8d4ce88a04664fe958f9850c6cb907cc6fcf9
nginx 서비스 확인
$ curl localhost
Hello, World
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b292fd7387f7 web-image "/docker-entrypoint.…" 54 minutes ago Up 54 minutes 0.0.0.0:80->80/tcp web10
a6a913ac9e2a nginx "/docker-entrypoint.…" About an hour ago Up 28 seconds 80/tcp web
$ docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b292fd7387f7 web-image "/docker-entrypoint.…" 54 minutes ago Up 54 minutes 0.0.0.0:80->80/tcp web10
a6a913ac9e2a nginx "/docker-entrypoint.…" About an hour ago Up 2 seconds 80/tcp web
web 컨테이너 삭제
$ docker stop web
web
$ docker rm web
web
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b292fd7387f7 web-image "/docker-entrypoint.…" 56 minutes ago Up 56 minutes 0.0.0.0:80->80/tcp web10
$ docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b292fd7387f7 web-image "/docker-entrypoint.…" 56 minutes ago Up 56 minutes 0.0.0.0:80->80/tcp web10
출처: A CLOUD GURU
리눅스 공부방 오픈챗 : https://open.kakao.com/o/gO2LQBPb (비번: 2022)
관련자료
-
링크