docker-compose.yaml 内容
version: '2'
services:
myvueweb:
build: .
ports:
- "3000:80"
image: myvueweb
nginx.conf
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 20m;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Dockerfile 内容
# 设置基础镜像
FROM nginx:latest
# 定义作者
MAINTAINER zy
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
RUN echo 'echo init ok!!'
启动
docker-compose -f docker-compose.yaml up --build -d
看看容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d75fca406d3d myvueweb "nginx -g 'daemon ..." 17 minutes ago Up 17 minutes 0.0.0.0:3000->80/tcp myvue_myvueweb_1
看看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
myvueweb latest 9c6bd8a60bbb 22 minutes ago 127 MB
访问网页
curl http://192.168.134.129:3000