When docker created the nginx container, it was wrong to mount the configuration file, and the boss was eager to mention it! Thank you!

docker and ngixn image information are as follows:

root@iZ28q62x60iZ:/srv/testServer-sharp 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-sharp 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-sharp 

the first command, docker is misspelled.

the error message of the second command is obvious:

$PWD/conf/nginx.conf is the directory, and / etc/nginx/nginx.conf in the mirror is regular file, volume mount failed.

how to solve the rest should not be prompted, it should be deleted, it should be built

it is recommended to take a closer look at the directory structure of the configuration files in the nginx image, such as / etc/nginx/conf.d/,. If you only add server block, you do not have to modify the default setting

.
Menu