8
自己打包Docker镜像并部署Vue项目
source link: https://codeyang.pages.dev/archives/Docker1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
一只会敲代码的Sheep
自己打包Docker镜像并部署Vue项目
发表于2021-12-25|更新于2021-12-25|Docker,Vue
字数总计:229|阅读时长:1分钟|阅读量:8
- Vue打包的项目(dist)
- Dockerfile
- nginx.conf
- Docker环境
编写Dockerfile
dockerfile
FROM nginx
COPY ./dist/ /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/nginx.conf
编写nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
client_max_body_size 20m;
server {
listen 80;
server_name www.koyang.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
}
在当前目录打开terminal
docker build -t vue-demo .
这样就生成了一个名为vue-demo
的镜像包
docker run --name vue -p 8080:80 -d vue-demo
浏览器输入localhost:8080就可以访问了前端页面了
推送镜像到Docker hub
docker login
修改镜像tag
docker tag 原镜像名 注册用户名/镜像名
docker push boonyadocker/tomcat-allow-remote:latest
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK