# Discourse 컨테이너가 unattended-upgrades를 사용합니까?

**URL:** https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296
**Category:** Self-hosting
**Tags:** hosting
**Created:** [12월 17, 2019, 9:47오전 UTC](https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296 "2019-12-17T09:47:45Z")
**Posts on this page:** 1
**Showing post:** 9

<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: [4월 23, 2020, 10:26오전 UTC](https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296/9 "2020-04-23T10:26:11Z")

</div>

참고로, `unattended-upgrades` 설치 문제(실제로 Discourse Docker 컨테이너에서는 systemd 없이 실행되지 않음)를 크론 작업(cron job)을 통해 실행하도록 트리거를 설정하여 수정했습니다.

필요한 크론 작업을 생성하기 위해 `/var/discourse/templates/` 디렉터리에 다음 YAML 템플릿 파일을 생성했습니다(Debian 기반 Discourse Docker 이미지에 포함된 [크론 버그를 수정](https://meta.discourse.org/t/cron-in-docker-container-cannot-make-remove-an-entry-for-the-specified-session/148969/2)하는 명령도 포함되어 있음에 유의):

```plaintext
cat << EOF > /var/discourse/templates/unattended-upgrades.template.yml
run:
  - file:
     path: /etc/cron.d/unattended-upgrades
     contents: |+
        ################################################################################
        # File: /etc/cron.d/unattended-upgrades
        # Version: 0.2
        # Purpose: run unattended-upgrades in lieu of systemd. For more info see
        # * https://wiki.opensourceecology.org/wiki/Discourse
        # * https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296/3
        # Author: Michael Altfield <michael@opensourceecology.org>
        # Created: 2020-03-23
        # Updated: 2020-04-23
        ################################################################################
        20 04 * * * root /usr/bin/nice /usr/bin/unattended-upgrades --debug
        

  - exec: /bin/echo -e "\n" >> /etc/cron.d/unattended-upgrades
  # fix the Docker cron bug https://stackoverflow.com/questions/43323754/cannot-make-remove-an-entry-for-the-specified-session-cron
  - exec: /bin/sed --in-place=.\`date "+%Y%m%d_%H%M%S"\` 's%^\([^#]*\)\(session\s\+required\s\+pam_loginuid\.so\)$%\1#\2%' /etc/pam.d/cron
EOF

```

위 템플릿 파일을 활성화하려면 애플리케이션의 YAML 파일에 있는 `templates` 목록에 추가해야 합니다. 예를 들어,

```plaintext
[root@osestaging1 discourse]# head -n20 /var/discourse/containers/app.yml
## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/unattended-upgrades.template.yml"
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
# - "templates/web.socketed.template.yml"
  - "templates/web.modsecurity.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"
[root@osestaging1 discourse]# 

```

---

_[View the full topic](https://meta.discourse.org/t/does-discourse-container-use-unattended-upgrades/136296)._
