tee Dockerfile <<-‘EOF‘
FROM ubuntu:18.04
LABEL maintainer="james@example.com"
ENV REFRESHED_AT 2014-06-01
RUN apt-get -qq update && apt-get -qq install nginx
RUN mkdir -p /var/www/html/website
ADD nginx/global.conf /etc/nginx/conf.d/
ADD nginx/nginx.conf /etc/nginx/
EXPOSE 80
EOF
tee nginx.conf <<-‘EOF‘
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;
events { }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
}
EOF
tee global.conf <<-‘EOF‘
server {
listen 0.0.0.0:80;
server_name _;
root /var/www/html/website;
index index.html index.htm;
access_log /var/log/nginx/default_access.log;
error_log /var/log/nginx/default_error.log;
}
EOF
tee index.html <<-‘EOF‘
<head>
<title>Test website</title>
</head>
<body>
<h1>This is a test website</h1>
</body>
EOF
docker build -t whalefall541/nginx .
docker run -d -p 80 --name website -v $PWD/website:/var/www/html/website:rw whalefall541/nginx:v1 nginx
原文:https://www.cnblogs.com/whalefall541/p/14342689.html