0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

バージョン不一致でdockerのpostgresqlに接続できなくなった件

Last updated at Posted at 2021-12-14

gitリポジトリを更新したらローカルDBに接続できなくなった

表題の件解決にいたるまでの覚書です。

プロジェクトのphpのバージョンが8.1になったということなので
git pullしてローカルをアップデートしたら
dockerのコンテナの1つが立ち上がらなくなってDBに接続できなくなった。

とりあえずdockerのログを確認する。

The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.1.

docker.PNG

バージョンの不一致らしい。phpのバージョンアップと共にpostgresのバージョンも上げたようだ。
なのでpostgresqlのバージョンを13.5→14.1に上げた・・・が立ち上げなおしても上記のエラーが出続ける。
ネットで上記のエラーログを検索してもバージョンアップorダウンで対応しているものが多数で自分のケースにそのまま当てはめるのが難しそう。

最終的に解決した方法

色々試したが今回は最終的にdockerのvolumeを削除して立ち上げなおすことでなおった
docker2.PNG

解決するまでに試した方法

・docker compose rm -f コンテナ名
・コンテナを全て削除してビルドしなおす
・コンテナ、イメージを全て削除してビルドしなおす
・Dockerfileの修正
(修正前)yum install -y postgresql13 && \
(修正後)yum install -y postgresql14 && \

解決法がわかっていれば作業自体は一瞬で終わるのだが
そもそもdockerをよく理解してないものだからこの程度でも原因を探すのに苦労するのである。
1個ずつ覚えていきたい。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?