http://dockone.io/article/8834 docker部署教程
docker pull nginx
// -i 以交互模式运行容器,通常与 -t 同时使用
// -t 为容器重新分配一个伪输入终端,通常与 -i 同时使用
// -p 参数将一个docker主机的端口映射到容器中
// -it 参数一般连用,在docker run 启动一个容器后提供一个容器的终端,如果容器中没开启shell进程,
// 也无法对容器进行交互
docker run -it -p 8848:80 -d nginx:latest
docker rm $(docker ps -a -q) 删除所有停止的容器
http://47.102.213.11:8848/ 访问nginx
docker rm 容器id
docker images|grep none|awk '{print $3}'|xargs docker rmi 删除tag为空的镜像
# 设置基础镜像
FROM nginx:latest
# 定义作者
MAINTAINER Rockwc <1370707974@qq.com>
# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面
COPY dist/ /usr/share/nginx/html/myvue/
COPY nginx.conf /etc/nginx/nginx.conf
RUN echo 'echo init ok!!'
// -t 指定了镜像名为docker-vue
// . 代表着当前目录
docker build -t myvue .
//-d 后台运行容器,并返回容器ID
docker run -p 88:1996 -d myvue
配置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;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 1996;
server_name *.*.*.*; //自己的服务器ip
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 1995;
server_name *;//自己的服务器ip
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
#root html;
#index index.html index.htm;
#}
location / {
root /usr/share/nginx/html/myvue;
index index.html;
try_files $uri $uri/ /index.html;
}
location /dev-api {
rewrite /dev-api/(.*) /$1 break;
proxy_pass http://*; #此处修改为自己的请求地址,必填
}
###api为本地开发时,在config/index.js中的proxyTable: {}配置的请求代理
###根据具体情况修改
#location = /index.html {
# add_header Cache-Control "no-cache, no-store";
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}