# Docker로 로컬에서 Discourse를 실행할 때 Postgres가 실행되지 않는 것 같습니다

**URL:** https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539
**Category:** Support
**Created:** [2월 21, 2025, 7:47오전 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539 "2025-02-21T07:47:39Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![GregorSondermeier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gregorsondermeier/32/299039_2.png) [@GregorSondermeier](https://meta.discourse.org/u/GregorSondermeier)
#### Post date: [2월 21, 2025, 7:47오전 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/1 "2025-02-21T07:47:39Z")

</div>

저희 회사에서는 Discourse 인스턴스의 REST API를 대상으로 몇 가지 기능을 개발해야 합니다. 로컬 개발 및 테스트를 위해 [https://meta.discourse.org/t/102009](https://meta.discourse.org/t/102009) 링크의 안내를 꽤 오랫동안 성공적으로 따르고 있었습니다.

마지막으로 개발을 진행한 지 몇 주가 지났습니다. 어제 로컬에서 Discourse를 다시 실행해 보기 위해 평소처럼 `git pull && d/boot_dev && d/bundle install && d/rails s` 명령어를 실행했습니다. 그러나 마지막 명령어인 `d/rails s`가 다음과 같은 오류와 함께 실패했습니다:

```bash
URGENT: Failed to initialize site default: ActiveRecord::ConnectionNotEstablished connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

/home/discourse/.bundle/gems/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:69:in `rescue in new_client'
[...]

```

_discourse\_dev_ 컨테이너로 터미널을 열고 `ls -la /var/run/postgresql/`를 실행해 보니, 실제로 `.s.PGSQL.5432` 소켓이 존재하지 않았습니다.

아, 그렇다면 처음부터 무작정 `git pull`을 실행하지 말았어야 했나 싶어 [tag v4.4.0](https://github.com/discourse/discourse/tree/v3.4.0)과 [tag v3.3.0](https://github.com/discourse/discourse/tree/v3.3.0)으로 체크아웃을 하고 다시 시도해 보았습니다. 하지만 동일한 오류가 발생했습니다.

_discourse\_dev_ 컨테이너 내부에서 Postgres 데이터베이스가 실행되지 않는 것처럼 보입니다.

이상한 점은, [discourse 저장소](https://github.com/discourse/discourse)를 새 폴더에 클론하고(예, _main_ 브랜치의 최신 코드까지 포함하여) Docker를 사용해 Discourse를 실행하면 이 오류가 발생하지 않고 Discourse가 성공적으로 시작됩니다.  
물론 이때 데이터베이스는 비어 있는 상태라 다소 불행한 상황입니다. 데이터가 _tmp/postgres_에 영속화된다는 점은 이해하고 있으며, 이를 기존 폴더에서 새 폴더로 복사해 올 수 있습니다. 하지만 어제는 그 사실을 몰랐고, 어제 문제 해결을 시도하던 중 모든 임시 폴더와 _node\_modules_ 폴더, _.pnpm-store_ 폴더 등을 삭제해 버렸습니다. 하지만 문제는 여전히 지속되고 있습니다.

**여기서 무슨 일이 일어나고 있는지, 또는 이 문제를 해결하기 위해 무엇을 할 수 있는지 아시는 분이 계신가요?**

---

<div class="post-metadata">

### Author: ![GregorSondermeier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gregorsondermeier/32/299039_2.png) [@GregorSondermeier](https://meta.discourse.org/u/GregorSondermeier)
#### Post date: [2월 21, 2025, 8:27오전 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/2 "2025-02-21T08:27:35Z")

</div>

내 로컬 데이터에 뭔가 완전히 깨져서 postgres가 시작되지 않는 것 같습니다.

`sudo cp -pr discourse/data/postgres discourse2/data/postgres`를 실행하면 `discourse2` 폴더에서 Discourse를 부팅할 때 정확히 같은 문제가 발생합니다. 반대로, `discourse/data/postgres`를 삭제하면 원래의 discourse 인스턴스는 정상적으로 부팅되지만, 당연히 데이터는 없습니다 ☹

---

<div class="post-metadata">

### Author: ![mwaniki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mwaniki/32/313097_2.png) [@mwaniki](https://meta.discourse.org/u/mwaniki)
#### Post date: [2월 21, 2025, 1:21오후 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/3 "2025-02-21T13:21:04Z")

</div>

불편을 드려 죄송합니다. 이는 최근의 [PostgreSQL 15 update](https://meta.discourse.org/t/postgresql-15-update/349515) 업데이트 때문일 가능성이 높습니다. 이전 PG 13 데이터 파일은 현재 PG 15를 실행하는 `discourse_dev` 이미지와 호환되지 않으며, 자동화된 데이터베이스 업데이트 절차는 개발 환경을 위해 설계된 것이 아니었습니다.

구체적인 이유 없이 기존 데이터 파일을 유지하려는 이유가 있으신가요?

> [@GregorSondermeier](#):
>
> 물론 데이터 없이

컨테이너 내에서 `rake dev:populate`를 실행하면 테스트 데이터를 생성할 수 있습니다.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2월 21, 2025, 1:53오후 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/4 "2025-02-21T13:53:55Z")

</div>

그 가이드는 사용하지 마세요. 업데이트하거나 삭제해야 합니다.

이것을 사용하세요: [Developing Discourse using a Dev Container](https://meta.discourse.org/t/developing-discourse-using-a-dev-container/336366?silent=true)

---

<div class="post-metadata">

### Author: ![GregorSondermeier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gregorsondermeier/32/299039_2.png) [@GregorSondermeier](https://meta.discourse.org/u/GregorSondermeier)
#### Post date: [2월 21, 2025, 4:12오후 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/5 "2025-02-21T16:12:00Z")

</div>

> [@mwaniki](#):
>
> 이것은 최근의 [PostgreSQL 15 업데이트](https://meta.discourse.org/t/postgresql-15-update/349515) 때문일 가능성이 높습니다.

아, 정말 많은 부분이 이해가 됩니다. 설명해 주셔서 감사합니다. `main` 브랜치에서 `git pull`을 무분별하게 실행하는 것은 의도치 않게 많은 것을 깨뜨릴 수 있으므로 어쨌든 나쁜 아이디어라는 것을 알게 되었습니다. 🙂

> [@mwaniki](#):
>
> 오래된 데이터 파일을 유지하려는 특별한 이유가 있나요?

관리 설정, 특히 [Discourse Connect](https://meta.discourse.org/t/13045)와 관련된 설정 때문일 뿐입니다. 또한 일부 REST API 설정, 일부 플러그인 설정 및 특정 수동 사용자 그룹도 있습니다. 카테고리와 사용자 그룹(그리고 그룹 멤버십)을 REST API를 통해 관리하는 독특한 SSO 설정을 갖추고 있습니다. 개발 중에는 게시글이나 답변과 같은 실제 콘텐츠에는 전혀 관심이 없기 때문에 `rake dev:populate`이 저에게 도움이 되지 않을 것이라 생각합니다.

부디 오해하지 마세요.

---

<div class="post-metadata">

### Author: ![mwaniki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mwaniki/32/313097_2.png) [@mwaniki](https://meta.discourse.org/u/mwaniki)
#### Post date: [2월 25, 2025, 8:49오전 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/6 "2025-02-25T08:49:49Z")

</div>

스테이징/프로덕션 사이트가 이미 PG 15로 업데이트된 경우, 해당 사이트에서 백업을 가져올 수 있습니다.

대안으로, 로컬 데이터 파일을 [수동으로 업데이트](https://meta.discourse.org/t/postgresql-15-update/349515/1#p-1698209-doing-a-manual-update-space-constrained-environments-4)해 볼 수 있습니다. 다음이 도움이 될 수 있습니다:

```plaintext
cd discourse
mkdir data/postgres_new
docker run --rm \
	--entrypoint=/bin/bash \
	-v "$(pwd)/data/postgres":/var/lib/postgresql/13/data \
	-v "$(pwd)/data/postgres_new":/var/lib/postgresql/15/data \
	tianon/postgres-upgrade:13-to-15 \
	-c "apt-get update && apt-get install -y postgresql-13-pgvector postgresql-15-pgvector &&
	docker-upgrade"
mv data/postgres data/postgres_old
mv data/postgres_new data/postgres
docker run --rm -v "$(pwd)/data/postgres":/postgres \
discourse/discourse_dev:release chown -R postgres:postgres /postgres

```

(ARM 기반 프로세서를 사용 중이라면, [이미지](https://github.com/tianon/docker-postgres-upgrade/tree/master/13-to-15)를 직접 빌드해야 합니다.)

---

<div class="post-metadata">

### Author: ![GregorSondermeier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gregorsondermeier/32/299039_2.png) [@GregorSondermeier](https://meta.discourse.org/u/GregorSondermeier)
#### Post date: [2월 25, 2025, 9:39오전 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/7 "2025-02-25T09:39:25Z")

</div>

건설적인 답변을 주셔서 정말 감사합니다!  
나와 내 동료들이 로컬 discourse 인스턴스를 3.4.0보다 더 높은 버전으로 업그레이드할 때 이 정보가 유용하게 쓰이겠네요.

하지만 당장은 새로운 데이터셋으로 시작해서 필요한 설정을 다시 적용했습니다. 다행히도 개발 동료들이 discourse 개발을 시작하는 방법을 안내하는 내부 문서가 이미 있었어요 🙂

---

<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: [3월 27, 2025, 9:40오전 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/8 "2025-03-27T09:40:20Z")

</div>

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