nginx之dockerfile编写方法

戚薇 Docker 发布时间:2023-06-01 09:44:35 阅读数:11272 1
下文笔者讲述nginx之dockerfile的编写方法分享,如下所示 例:nginx之dockerfile
FROM nginx:1.22.1

MAINTAINER "java265"

RUN groupadd --system -g 2000 app \
    && useradd app --system -m -s /bin/bash -u 2000 -g 2000 \
    && usermod -a -G nginx app

WORKDIR /home/app

#COPY app/start.sh .
#COPY app/docker-entrypoint-init.d docker-entrypoint-init.d
#COPY app/docker-entrypoint.sh /usr/local/bin/

COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/
COPY etc/nginx/nginx.conf /etc/nginx/

#RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
#    && ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh

RUN mkdir -p /home/app/log && mkdir -p /var/run/nginx \
    && chown -R app:app /home/app/log \
    && chown -R nginx:nginx /var/log/nginx \
    && chown -R nginx:nginx /var/cache/nginx \
    && chown -R nginx:nginx /usr/lib/nginx \
    && chown -R nginx:nginx /var/cache/nginx \
    && chown -R nginx:nginx /var/run/nginx \
    && chmod -R 775 /var/cache/nginx \
    && chmod -R 775 /var/log/nginx \
    && chown nginx:nginx /usr/sbin/nginx \
    && chmod a+s /usr/sbin/nginx

USER nginx

#ENTRYPOINT ["docker-entrypoint.sh"]
例2
FROM nginx:1.22.1

MAINTAINER "java265"

RUN cp /etc/apt/sources.list /etc/apt/sources.list.backup \
    && sed -i "s@http://\(deb\|security\).debian.org@https://mirrors.aliyun.com@g" /etc/apt/sources.list \
    && apt-get update && apt-get install -y apt-utils

RUN apt-get install -y vim wget telnet net-tools tcpdump

COPY etc/nginx/conf.d/default.conf /etc/nginx/conf.d/
COPY etc/nginx/nginx.conf /etc/nginx/

RUN mkdir -p /var/run/nginx && chown -R nginx:nginx /var/run/nginx \
    && chown -R nginx:nginx /var/cache/nginx \
    && chown -R nginx:nginx /var/log/nginx \
    && chown -R nginx:nginx /var/lib/nginx

USER nginx
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

本文链接: https://www.Java265.com/docker/202306/6676.html

最近发表

热门文章

好文推荐

Java265.com

https://www.java265.com

站长统计|粤ICP备14097017号-3

Powered By Java265.com信息维护小组

使用手机扫描二维码

关注我们看更多资讯

java爱好者