# Docker 컨테이너 안에서 Discourse의 nginx 서비스를 재시작하는 방법?

**URL:** https://meta.discourse.org/t/how-to-restart-discorses-nginx-service-inside-the-docker-container/133187
**Category:** Self-hosting
**Created:** [11월 12, 2019, 11:22오전 UTC](https://meta.discourse.org/t/how-to-restart-discorses-nginx-service-inside-the-docker-container/133187 "2019-11-12T11:22:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![maltfield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maltfield/32/160669_2.png) [@maltfield](https://meta.discourse.org/u/maltfield)
#### Post date: [11월 12, 2019, 11:22오전 UTC](https://meta.discourse.org/t/how-to-restart-discorses-nginx-service-inside-the-docker-container/133187/1 "2019-11-12T11:22:50Z")

</div>

Discourse Docker 컨테이너 안에서 nginx를 다시 시작하는 올바른 방법은 무엇인가요?

Docker 컨테이너에는 Debian 10이 설치되어 있는 것으로 보이지만, nginx를 다시 시작하는 일반적인 systemd 방식이 실패합니다.

```plaintext
[root@osestaging1 discourse]# ./launcher enter discourse_ose
root@osestaging1-discourse-ose:/var/www/discourse# cat /etc/issue
Debian GNU/Linux 10 \n \l

root@osestaging1-discourse-ose:/var/www/discourse# systemctl restart nginx
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
root@osestaging1-discourse-ose:/var/www/discourse# 

```

init.d 스크립트가 있는 것으로 보이지만, 이를 실행해도 실패합니다. 로그에는 이미 사용 중인 주소에 바인드할 수 없어서라고 나와 있습니다.

```plaintext
root@osestaging1-discourse-ose:/etc/nginx/conf.d# /etc/init.d/nginx restart
[FAIL] Restarting nginx: nginx failed!
root@osestaging1-discourse-ose:/etc/nginx/conf.d# tail /var/log/nginx/error.log
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:45 [emerg] 1123#1123: still could not bind()
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)
2019/11/12 10:32:47 [emerg] 1127#1127: bind() to unix:/shared/nginx.http.sock failed (98: Address already in use)

```

실제로 nginx는 이미 실행 중입니다.

```plaintext
root@osestaging1-discourse-ose:/etc/nginx/conf.d# ps -ef | grep -i nginx
root 46 40 0 10:19 ? 00:00:00 runsv nginx
root 1174 46 1 10:33 ? 00:00:00 /usr/sbin/nginx
root 1177 108 0 10:33 pts/1 00:00:00 grep -i nginx
root@osestaging1-discourse-ose:/etc/nginx/conf.d# 

```

위 nginx 프로세스를 종료하고 다시 시작하는 올바른 방법은 무엇인가요?

---

<div class="post-metadata">

### Author: ![maltfield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maltfield/32/160669_2.png) [@maltfield](https://meta.discourse.org/u/maltfield)
#### Post date: [11월 12, 2019, 11:26오전 UTC](https://meta.discourse.org/t/how-to-restart-discorses-nginx-service-inside-the-docker-container/133187/2 "2019-11-12T11:26:14Z")

</div>

Discourse 도커 컨테이너 내에서 nginx를 다시 시작하는 올바른 방법은 `runit` 서비스 슈퍼바이저의 일부인 `sv` 명령을 사용하는 것입니다.

```plaintext
root@osestaging1-discourse-ose:/var/www/discourse# sv stop nginx
ok: down: nginx: 1s, normally up
root@osestaging1-discourse-ose:/var/www/discourse# sv start nginx
ok: run: nginx: (pid 269) 0s
root@osestaging1-discourse-ose:/var/www/discourse# 

```

따라서 Ruby on Rails가 runit을 사용하는 것으로 보입니다.

- [runit - Wikipedia](https://en.wikipedia.org/wiki/Runit)

[templates/web.template.yml 파일](https://github.com/discourse/discourse_docker/blob/7440820f554b3db7d8ab5c2970debe64b3a70d57/templates/web.template.yml#L76)에서 `sv` 명령이 참조되고 있음을 확인했습니다.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [11월 13, 2019, 1:22오전 UTC](https://meta.discourse.org/t/how-to-restart-discorses-nginx-service-inside-the-docker-container/133187/3 "2019-11-13T01:22:55Z")

</div>

> [@maltfield](#):
>
> 그러니까 Ruby on Rails가 runit을 사용하는 것 같군요

거의 맞습니다… Ruby on Rails는 어떤 것을 사용할지에 대해 중립적인 입장을 취합니다. systemd, docker에서 직접 pid 1을 사용하거나, 그 밖의 수많은 도구를 사용할 수 있습니다.

우리는 공식 docker 이미지에서 `runit`을 사용하기로 결정했는데, 그 이유는 가볍고 동작 방식을 파악하기가 매우 쉽기 때문입니다. 그것은 그저 작동하는 도구입니다.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [12월 13, 2019, 1:36오전 UTC](https://meta.discourse.org/t/how-to-restart-discorses-nginx-service-inside-the-docker-container/133187/4 "2019-12-13T01:36:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
