jeudi 21 janvier 2016

Run nginx in docker with custom vhost

I want to run basic nginx container on OSX with docker machine.

I run the following code:

docker pull nginx
docker run -d -i -t \
    -p 8080:80 \
    -v $(pwd)/vhost.conf:/etc/nginx/sites-enabled/vhost.conf \
    -v $(pwd)/docker.dev:/var/www/docker.dev nginx

In current directory I have vhost.conf file:

server {
    listen 80;
    index index.html;
    server_name docker.dev;
    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log
    root /var/www/docker.dev
}

and docker.dev folder with index.html file in it.

Also in my /etc/hosts on my host OSX system I have:

192.168.99.100 docker.dev

But when I visit http://ift.tt/1N1yiIz in browser I get default nginx page, not my index.html

I can achieve the desired result by placing index.html file in /usr/share/nginx/html folder. But I want to figure out how can I adjust my own location for web root.




Aucun commentaire:

Enregistrer un commentaire