1. 程式人生 > 其它 >P2520 [HAOI2011]向量 題解

P2520 [HAOI2011]向量 題解

安裝以及啟動

docker pull nginx

docker run -d -p 80:80 --name kaka-nginx --net host -v /kaka-data/nginx/www:/usr/share/nginx/html -v /kaka-data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /kaka-data/nginx/logs:/var/log/nginx --privileged nginx

出現的問題

執行docker run的時候報的錯

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/kaka-data/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

解決的辦法

  • 先暫時把-v /docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf 去掉
  • 再次啟動docker run -d -p 80:80 --name kaka-nginx --net host -v /kaka-data/nginx/www:/usr/share/nginx/html -v /kaka-data/nginx/logs:/var/log/nginx --privileged nginx
  • 發現可以成功啟動
  • 然後進入nginx容器把配置檔案複製到 /kaka-data/nginx/conf/ 裡面
第一步:docker exec -it kaka-nginx /bin/bash (進入容器 獲取檔案)
第二步:cd /etc/nginx/ (這裡主要獲取配置檔案路徑的)
第三步:exit
第四步:cd /docker/nginx/conf/
第五步:docker cp 2ae68080aaca:/etc/nginx/nginx.conf .
ps:檔案copy成功後 把nginx容器先刪除掉
第六步:docker rm kaka-nginx
第七步:docker run -d -p 80:80 --name kaka-nginx --net host -v /kaka-data/nginx/www:/usr/share/nginx/html -v /kaka-data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /kaka-data/nginx/logs:/var/log/nginx --privileged nginx

驗證訪問


在/kaka-data/nginx/www/裡面新建index.html即可,然後再次訪問