Nit*_*n G 3 nginx docker dockerfile alpine-linux nginx-reverse-proxy
我们正在尝试在基于 java 的 alpine 镜像 ( ) 上安装并运行 nginx anapsix/alpine-java:7_jdk,但启动时遇到以下错误
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
Run Code Online (Sandbox Code Playgroud)
我们已经尝试了很多文章,但没有提到如何修复这个基于 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
Run Code Online (Sandbox Code Playgroud)
请帮助我们实现这一目标。
anapsix/alpine-java:7_jdk看到这个惊人的答案后,我设法让 Nginx 在图像中工作。
这是一个有效的 Dockerfile:
FROM anapsix/alpine-java:7_jdk
COPY script.bash .
RUN apk --update add nginx openrc
RUN openrc
RUN touch /run/openrc/softlevel
CMD bash ./script.bash
Run Code Online (Sandbox Code Playgroud)
这是script.bash用于CMD:
#!/bin/bash
# Tell openrc loopback and net are already there, since docker handles the networking
echo 'rc_provide="loopback net"' >> /etc/rc.conf
# get inside the container bash
bash
Run Code Online (Sandbox Code Playgroud)
docker build . -t nginx_alpine_java使用运行以下命令构建图像后:
docker run -it -p 80:80 nginx_alpine_java
现在我们正在容器狂欢中
bash-4.3# rc-service nginx status
* status: stopped
bash-4.3# rc-service nginx start
* /run/nginx: creating directory
* /run/nginx: correcting owner [ ok ]
* Starting nginx ... [ ok ]
Run Code Online (Sandbox Code Playgroud)
我希望它能与您合作。
| 归档时间: |
|
| 查看次数: |
2441 次 |
| 最近记录: |