0

I've created a simple Docker container with Nginx inside and for some reason, it won't access the www volume data from the host.

Here is the command I used:

docker run \
    -d \
    -p 8080:80 \
    --name nginx \
    --restart always \
    -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
    -v /var/www:/usr/share/nginx/html \
    -v /home/myuser/myvhost.conf:/etc/nginx/sites-enabled/myvhost.conf:ro \
    -v /var/log/nginx:/var/log/nginx \
    nginx:1.9.4;

All the volumes are correctly mounted (I checked with docker inspect) but when go on the website I get a 404 and the Nginx error.log on the host says:

"/var/www/docker/index.html" is not found (2: No such file or directory)

It's surprising because this path is definitely correct...

0

1 Answer 1

1

Nginx is looking for content in /var/www, and you don't appear to be mounting anything on /var/www.

You are mounting your host's /var/www on /usr/share/nginx/html inside the container.

It looks like you either need to (a) modify your ngingx configuration, or (b) mount your hosts's /var/www inside the container as /var/www, or (c) you have some of your -v specifications backwards (the syntax is -v <host_path>:<container_path>)

1
  • You were right, -v /var/www:/var/www fixed my issue. Aug 31, 2015 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.