目录
一、Compose部署
1.1.1、安装docker环境
Yum -y install docker-ce
1.1.2、下载compose
Curl-L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
1.1.3、创建compose文件夹
Madir compose_nginx
Cd compose_nginx #进入
1.1.4、创建nginx文件夹
Mkdir Nginx
Cd nginx
#创建dockerfile文件
vim Dockerfile
cat Dockerfile
FROM centos:7
MAINTAINER this is nginx
RUN yum -y update
RUN yum -y install gcc gcc-c++ make pcre-devel expat-devel perl zlib-devel
RUN useradd -M -s /sbin/nologin nginx
ADD nginx-1.12.2.tar.gz /usr/local/src
WORKDIR /usr/local/src/nginx-1.12.2
RUN ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module && make && make install
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80
EXPOSE 443
RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
ADD run.sh /run.sh
RUN chmod 755 /run.sh
CMD ["/run.sh"]
把安装包导到同一目录
cd … 退回上一级
vim docker-compos.yaml
version: '3'
services:
nginx:
hostname: nginx
build:
context: ./nginx
dockerfile: Dockerfile
ports:
- 1216:80
- 1217:443
networks:
- cluster
volumes:
- ./wwwroot:/usr/local/nginx/html
networks:
cluster:
docker-compose -f /root/compose_nginx/docker-compos.yaml up -d
1.1.5、创建测试网页index.html
测试: 访问:192.168.100.131:1216