docker安装
https://blog.csdn.net/hanzheng260561728/article/details/86216058
创建目录
mkdir centos_nginx
cd centos_nginx
创建自动脚本
vi Dockerfile
#Specify which base image to use
FROM centos
MAINTAINER Dirk.Wang [email protected]
LABEL Discription="Nginx image based on CentOS" version="1.0"
WORKDIR /usr/local/src
RUN yum install -y wget
RUN wget http://nginx.org/download/nginx-1.15.2.tar.gz
RUN tar -zxvf nginx-1.15.2.tar.gz
WORKDIR nginx-1.15.2
RUN yum -y install gcc-c++ gcc
RUN yum -y install pcre pcre-devel
RUN yum -y install zlib zlib-devel
RUN yum -y install openssl openssl-devel libssl-dev autoconf automake make
RUN useradd -s /sbin/nologin -M www
RUN ./configure --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_dav_module --with-http_sub_module --with-http_gunzip_module --with-pcre --with-debug
RUN make
RUN make install
EXPOSE 80
安装
docker build -t centos_nginx .
查看容器
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos_nginx latest e49a3e7bd192 7 minutes ago 525.6 MB
创建容器
docker run -dit -p 80:80 --name nginx centos_nginx
03d0aa7beadadf903027931833ec0de96b894d0854437ee4c50c93f5dddeaf33
进去容器启动nginx
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7678adaf7e2f centos_nginx "/bin/bash" 17 seconds ago Up 16 seconds 0.0.0.0:8085->80/tcp nginx
docker attach nginx