Postgres容器不断重启

时间:2019-08-09 19:35:23

标签: ruby-on-rails postgresql docker docker-compose docker-volume

对于我的本地Rails开发,我使用的是来自标准docker映像的postgres数据库设置。但是,我犯了运行docker build .的错误。现在,当我尝试启动postgres容器时,出现错误:

db_1   | initdb: directory "/var/lib/postgresql/data" exists but is not empty
db_1   | It contains a dot-prefixed/invisible file, perhaps due to it being a mount point.
db_1   | Using a mount point directly as the data directory is not recommended.
db_1   | Create a subdirectory under the mount point.

这是我的docker-compose.yml

version: '3.2'
volumes:
  pg_data:
services:
  db:
    image: postgres
    ports:
      - "5433:5432"
    restart: unless-stopped
    volumes:
      - ./pg_data:/var/lib/postgresql/data
  web:
    build: .
    command: bundle exec rails s -p 3001 -b '0.0.0.0'
    env_file:
      - variables.env
    volumes:
      - .:/my_app
    ports:
      - "3001:3001"
    depends_on:
      - db
    restart: unless-stopped
    stdin_open: true
    tty: true

Dockerfile

FROM ruby:2.3.3
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /my_app
WORKDIR /my_app
ADD Gemfile /my_app/Gemfile
ADD Gemfile.lock /my_app/Gemfile.lock
RUN bundle install
ADD . /my_app

我希望重用到目前为止积累的数据。如果我需要从本地开始,就这样吧,我想如果要这样做,我必须删除持久卷。我不太确定要诚实。我不太担心在生产服务器上发生这种情况,因为我们正在服务器上使用实际的Postgres安装。

目录树:


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2017-07-26   9:52 AM                app
d-----       2017-07-26   9:52 AM                bin
d-----       2018-02-12   4:28 PM                config
d-----       2018-02-12   4:28 PM                db
d-----       2017-07-27  11:43 AM                lib
d-----       2017-08-31   2:51 PM                log
d-----       2018-01-18   1:35 PM                pg_data
d-----       2018-02-01   2:09 PM                public
d-----       2017-07-26   9:52 AM                test
d-----       2017-07-26  10:35 AM                tmp
d-----       2017-07-26   9:52 AM                vendor
-a----       2017-07-31   9:56 AM             14 .byebug_history
-a----       2018-02-12   4:28 PM            605 .gitignore
-a----       2017-07-26   9:52 AM            130 config.ru
-a----       2018-11-13  11:32 AM            478 docker-compose.yml
-a----       2019-07-19   8:54 AM            521 Dockerfile
-a----       2019-08-09   2:41 PM           2297 Gemfile
-a----       2018-02-12   4:28 PM           6434 Gemfile.lock
-a----       2017-07-26   9:52 AM             71 package.json
-a----       2017-07-26   9:52 AM            227 Rakefile
-a----       2019-05-30   1:49 PM            599 README.md
-a----       2017-12-12   9:50 AM             92 variables.env

编辑/更新

经验教训:周五,在不到一个小时的时间内不要破坏任何东西,然后前往周末……大声笑

更新2: 添加了目录树

更新3: 重新启动似乎已完成,因为数据库/ postgres容器可以正常启动。但是,我以前的数据似乎没有持久化。我猜这是与我的卷配置/设置有关的问题,但不确定。

0 个答案:

没有答案