【发布时间】:2021-11-12 01:23:36
【问题描述】:
我们正在尝试在基于 java 的 alpine 映像 (anapsix/alpine-java:7_jdk) 上安装和运行 nginx,但是当我们启动它时遇到以下错误
rc-service nginx start
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/blkio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/cpu/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/cpu,cpuacct/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/cpuacct/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/cpuset/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/devices/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/freezer/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/hugetlb/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/memory/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/net_cls/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/net_cls,net_prio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/net_prio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/perf_event/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/pids/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 250: can't create /sys/fs/cgroup/systemd/tasks: Read-only file system
* Starting networking ...
awk: /etc/network/interfaces: No such file or directory
* ERROR: networking failed to start
* ERROR: cannot start nginx as networking would not start
我们已经尝试了很多文章,但没有提到如何在这个基于 alpine 的图像上修复 nginx 的网络问题。即使我们创建了/etc/network/interfaces 文件,我们也不知道其中的正确值应该是什么。下面是我们正在运行的 Dockerfile
# Add Nginx
RUN apk --update add nginx openrc
RUN mkdir -p /run/nginx
RUN touch /run/nginx/nginx.pid
# RUN adduser -D -g 'nginx' nginx
# RUN mkdir /home/nginx
RUN chown -R nginx:nginx /var/lib/nginx
# RUN chown -R nginx:nginx /home/nginx
COPY birt.conf /etc/nginx/conf.d/birt.conf
# COPY index.html /nginx
RUN openrc
RUN touch /run/openrc/softlevel
RUN rc-update add nginx default
请帮助我们实现这一目标。
【问题讨论】:
-
也许看看官方的 nginx 镜像是如何构建的会有所帮助? github.com/nginxinc/docker-nginx/blob/…
-
嘿汉斯...感谢您的建议,但此答案stackoverflow.com/a/65734249/9548311 中给出的步骤几乎相同,但我们仍然面临问题
-
为什么需要java基础镜像?
-
因为我们在这个 docker 中运行基于 java/jboss 的进程 birt。所以我们需要发回一些包含主机/pod ip地址的响应头,因为我们试图通过nginx将流量路由到进程。
标签: docker nginx dockerfile nginx-reverse-proxy alpine