Vue Docker 部署筆記


前端 dockerfile 建構完成後

```
執行 docker build . -t <image ID>

//更改REPOSITORY 名稱
docker tag <image ID> <REPOSITORY Name>

//推送至docker hub
docker push <REPOSITORY Name>
```

### Docker 指令

進入 container 內

- sudo docker exec -it <_container Name_> bash

### nginx proxy default.conf 設定

```
server {
listen 80;
listen [::]:80;
server_name localhost;

#location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
#}

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://192.168.1.123:5000;

}


#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;
#}
}
```

### 容器無法啟動

```
docker cp nginx:/etc/nginx/conf.d/default.conf ./ ### 這裡是將容器內的文件複製到本地當前目錄
dokcer cp ./default.conf nginx:/etc/nginx/conf.d/ ### 這裡是將本地當前目錄的default.conf複製到容器內指定目錄

留言

這個網誌中的熱門文章

ES6 - 解構賦值

Git指令筆記