nginx镜像的构建

先查看下本地的镜像,选取官网的centos作为base image:

[root@server ~]# docker images

创建一个目录专门用来存放的目录,也就是Dockerfile所在的目录

[root@server ~]# mkdir myNginx
[root@server ~]# cd myNginx/
[root@server myNginx]# touch Dockerfile

编写Dockerfile文件的内容,注意该文件名字的首字母要大写。

[root@server myNginx]# cat Dockerfile
# 指定基础镜像
FROM centos

# MAINTAINER
MAINTAINER xxx@qq.com

# 安装基础工具包
RUN yum -y install wget gcc gcc-c++ glibc make autoconf openssl openssl-devel libxml2 libxml2-dev libxslt-devel gd-devel GeoIP GeoIP-devel GeoIP-data

# 下载nginx
ADD http://nginx.org/download/nginx-1.12.2.tar.gz /opt/nginx/

# 解压nginx 并创建用户
RUN tar -xvzf /opt/nginx/nginx-1.12.2.tar.gz -C /usr/local/src/ \
    && useradd -M -s /sbin/nologin nginx

# 更改工作目录
WORKDIR /usr/local/src/nginx-1.12.2

# 编译安装nginx
RUN ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module && make && make install

# 删除多余安装包 
RUN rm -rf /opt/nginx/nginx-1.12.2.tar.gz

# 设置环境变量
ENV PATH=/usr/local/nginx/sbin:$PATH

# 设置端口
EXPOSE 80
View Code

相关文章:

  • 2021-09-26
  • 2022-01-07
  • 2021-06-30
  • 2021-09-16
  • 2021-08-20
  • 2021-07-14
  • 2021-12-22
  • 2021-10-23
猜你喜欢
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案