Dmi*_*nov 9 postgresql docker docker-compose
Postgres容器在启动时崩溃并显示以下错误消息
(project) ? project git:(feature/62-api-custom-image-categories) ? docker-compose up postgres
Starting project_postgres_1 ...
Starting project_postgres_1 ... done
Attaching to project_postgres_1
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.3.
project_postgres_1 exited with code 1
Run Code Online (Sandbox Code Playgroud)
我有哪些选择?II 已更新图像到最新的
我的 docker-compose.yml 的一部分
version: '2'
volumes:
ipython_history: {}
services:
postgres:
image: mdillon/postgis
ports:
- "5432:5432"
environment:
- POSTGRES_DB=p_dev
- POSTGRES_USER=p_user
- POSTGRES_PASSWORD=password
Run Code Online (Sandbox Code Playgroud)
是否可以转换数据,或者唯一的选择是删除容器(丢失其所有数据)然后重新创建它?
pro*_*ils 13
另外不要忘记清除旧pgdata卷:
docker volume ls 进而 docker volume rm <volume-name>
否则你的错误仍然存在。
见https://github.com/ckan/ckan/issues/4164#issuecomment-388069003
我收到此错误是因为我始终使用最新版本的 postgres,而没有在末尾定义标签。然后最新版本切换到13,数据就不再兼容了。也许只是在最后添加一个版本也可能有所帮助。-> postgres: 12
postgres:
image: postgres:12
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
Run Code Online (Sandbox Code Playgroud)
你准时保存了,但是你需要回滚到以前的版本,然后:
docker exec -it <postgres-container-id> pg_dump db_name > local.dump.sql
Run Code Online (Sandbox Code Playgroud)
然后,检查转储正常后,清空数据库卷,升级postgres并恢复转储:
https://www.postgresql.org/docs/9.1/static/backup-dump.html