鍍金池/ 問答/Java  Linux/ docker 創(chuàng)建nginx容器時對配置文件進行掛載時報錯,有那大佬熱心提點提點

docker 創(chuàng)建nginx容器時對配置文件進行掛載時報錯,有那大佬熱心提點提點!感謝感謝?。。?!

docker 以及 ngixn鏡像信息如下:

root@iZ28q62x60iZ:/srv/testServer# docker -v
Docker version 18.03.1-ce, build 9ee9f40
root@iZ28q62x60iZ:/srv/testServer# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              649dcb69b782        19 hours ago        109MB
root@iZ28q62x60iZ:/srv/testServer# 

執(zhí)行錯誤報如下錯誤:

root@iZ28q62x60iZ:/srv/testServer# docekr run --name nginx -d -p 80:80 -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf nginx
No command 'docekr' found, did you mean:
 Command 'docker' from package 'docker.io' (universe)
docekr: command not found
root@iZ28q62x60iZ:/srv/testServer# docker run --name nginx -d -p 80:80 -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf nginx
4db2ddccc4022c305991a1dce568fd8332087d5543a56f4a573cde69de33feb8
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/srv/testServer/conf/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/3d4b01b3ed517480faba01aa1edb6fbb9e2dc01d5de5239e8c8d00d3a159777a/merged\\\" at \\\"/var/lib/docker/overlay2/3d4b01b3ed517480faba01aa1edb6fbb9e2dc01d5de5239e8c8d00d3a159777a/merged/etc/nginx/nginx.conf\\\" caused \\\"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.
root@iZ28q62x60iZ:/srv/testServer# 
回答
編輯回答
嫑吢丕

第一條命令,docker 拼錯了。

第二條命令的報錯信息很明顯:

$PWD/conf/nginx.conf 是目錄,而鏡像中的 /etc/nginx/nginx.conf 是 regular file, volume mount 失敗。

剩下怎么解決應該不用提示吧,該刪刪,該建建

建議仔細看下nginx鏡像中配置文件的目錄結(jié)構(gòu),比如 /etc/nginx/conf.d/, 如果只是增加 server block,不必修改默認設(shè)置

2017年10月3日 08:46