# dZone Docker Container **Repository Path**: longguorun/d-zone-docker-container ## Basic Information - **Project Name**: dZone Docker Container - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-27 - **Last Updated**: 2020-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 使用docker容器搭建blog 参考自 []: https://www.cnblogs.com/yufeng218/p/9398809.html ### dokcer容器的下载 1. nginx:最新 2. node:这里用的是slim版 ### server搭建 1. docker运行node镜像,暴露出3000端口 2. 将server源码拷入node容器 3. 下载pm2 4. 运行pm2 start ./index.js(此处的开机自启未实现) ### nginx挂载html文件 1. 在宿主机的两个配置文件,用于挂载后供nginx使用 > /opt/nginx/config/nginx.conf ``` user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } ``` > /opt/nginx/config/conf.d/default.conf ``` server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #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 /usr/share/nginx/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; #} } ``` 2. 宿主机运行命令 ```bash docker run \ --name pagesBlog \ -p 80:80 \ -v /root/blog/pearsonal-webpages/dist:/usr/share/nginx/html\ //html文件的放置路径 -v /opt/nginx/config/nginx.conf:/etc/nginx/nginx.conf \ -v /opt/nginx/config/conf.d:/etc/nginx/conf.d \ -v /opt/nginx/logs:/var/log/nginx \ -d xxxxxxxx //此处为nginx的镜像id ``` ### docker镜像导出与导入 1. 导出 ```bash docker export xxxx -o xxxx.tar ``` 2. 导入 ```bash docker import xxxx.tar 镜像名:tag ```