Reputation: 47
Hi I'm trying to bind nginx /usr/share/nginx/html directory to my linux home directory is this the right command to do it?
user@localhost ~: pwd
/home/user
sudo docker container run -d -p 8080:80 -v "$(pwd)":/usr/shares/nginx/html --name nginx-website nginx
But when I try to ls index.html is not showing.
Upvotes: 0
Views: 1332
Reputation: 11277
This is indeed the right command to mount your current directory (/home/user
here) to /usr/shares/nginx/html
. But be careful, you have probably made a mistake and wanted to use /usr/share/nginx/html
(share
folder instead of shares
).
Anyway, assuming this mistake is fixed, and if you have a /home/user/index.html
on your host, docker exec nginx ls index.html
shows nothing because the working directory of nginx
container is /
. Therefore, since ls index.html
is issued from /
, and there is no /index.html
, you don't see anything.
You have 2 solutions to see your index.html
:
docker exec -w /usr/share/nginx/html nginx ls index.html
index.html
via its absolute path : docker exec nginx ls /usr/share/nginx/html/index.html
Upvotes: 1