首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无根docker-compose无法构建时间刻度映像

无根docker-compose无法构建时间刻度映像
EN

Stack Overflow用户
提问于 2021-04-28 21:06:26
回答 1查看 133关注 0票数 1

我已经在ubuntu主机上安装了docker rootless。我有一个Dockerfile用于构建timescaledb,最重要的部分如下所示:

代码语言:javascript
复制
# Install the tools we need for installation
RUN  apt-get update && apt-get -y install gnupg2 lsb-release wget
# Add Postgres and Timescale package repository
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -c -s)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN sh -c "echo 'deb https://packagecloud.io/timescale/timescaledb/debian/ `lsb_release -c -s` main' > /etc/apt/sources.list.d/timescaledb.list"
RUN wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add -
# Install Timescale
RUN apt-get update && apt-get -y install timescaledb-2-postgresql-12=2.0.0-zz~debian10

对应的docker-compose文件如下所示:

代码语言:javascript
复制
  timescale:
    tty: true
    volumes:
      - timescale-volume:/var/lib/postgresql/data:rw
    build:
      context: ./timescale
      dockerfile: Dockerfile
    command:
      - /bin/bash
    depends_on:
      - cert-mounter

当我用sudo运行docker-compose up时,它工作得很好,镜像已经构建好了,容器也在运行。如果我在没有根目录的情况下执行它,我会得到以下错误:

代码语言:javascript
复制
dpkg: error processing package postgresql-12 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of timescaledb-2-postgresql-12:
 timescaledb-2-postgresql-12 depends on postgresql-12; however:
  Package postgresql-12 is not configured yet.

dpkg: error processing package timescaledb-2-postgresql-12 (--configure):
 dependency problems - leaving unconfigured
Setting up exim4-daemon-light (4.92-8+deb10u5) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Initializing GnuTLS DH parameter file
Setting up libmailutils5:amd64 (1:3.5-4) ...
Setting up mailutils (1:3.5-4) ...
update-alternatives: using /usr/bin/frm.mailutils to provide /usr/bin/frm (frm) in auto mode
update-alternatives: using /usr/bin/from.mailutils to provide /usr/bin/from (from) in auto mode
update-alternatives: using /usr/bin/messages.mailutils to provide /usr/bin/messages (messages) in auto mode
update-alternatives: using /usr/bin/movemail.mailutils to provide /usr/bin/movemail (movemail) in auto mode
update-alternatives: using /usr/bin/readmsg.mailutils to provide /usr/bin/readmsg (readmsg) in auto mode
update-alternatives: using /usr/bin/dotlock.mailutils to provide /usr/bin/dotlock (dotlock) in auto mode
update-alternatives: using /usr/bin/mail.mailutils to provide /usr/bin/mailx (mailx) in auto mode
dpkg: dependency problems prevent configuration of timescaledb-2-loader-postgresql-12:
 timescaledb-2-loader-postgresql-12 depends on postgresql-12; however:
  Package postgresql-12 is not configured yet.

dpkg: error processing package timescaledb-2-loader-postgresql-12 (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for mime-support (3.62) ...
Errors were encountered while processing:
 postgresql-common
 postgresql-12
 timescaledb-2-postgresql-12
 timescaledb-2-loader-postgresql-12
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get update && apt-get -y install timescaledb-2-postgresql-12=2.0.0-zz~debian10' returned a non-zero code: 100
ERROR: Service 'timescale' failed to build

可能的问题是什么?其他容器以某种方式构建并无根运行,没有问题……

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-29 00:26:19

所以我设法让它起作用了。在我的Dockerfile中,我还设置了用户的uid,因为我共享了一些卷,并且希望用户的UID在容器之间保持一致。因此,在我的Dockerfile之上,我有以下内容:

代码语言:javascript
复制
RUN useradd --uid 80000 postgres

用较低的值替换uid解决了这个问题

代码语言:javascript
复制
RUN useradd --uid 18000 postgres
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67300841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档