0
votes

I have docker-compose.yml with just nginx in it but when running it the volumes is not found inside the nginx container. The Dockerfile works fine in another setup and the src dir exists, so i dont understand why this doesnt work here?

Nginx says:

nginx_1 | 2015/06/04 09:33:32 [error] 13#0: *1 open() "/var/www/web/index.html" failed (2: No such file or directory), client: 172.17.42.1, server: , request: "GET /index.html HTTP/1.1", host: "localhost:8085"

tree:

.
├── code
├── docker-compose.yml
├── logs
├── nginx
└── readme.md

the docker-compose.yml

nginx:
    build: nginx/
    volumes:
        - code/dist:/var/www
    ports:
        - 8085:80

The Dockerfile:

FROM ubuntu:14.04

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y \
    nginx

RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
ADD vhost.conf /etc/nginx/sites-enabled/default

ADD start.sh /start.sh
EXPOSE 80

ENTRYPOINT ["/start.sh"]

Update

When i rename the nginx to othernginx in docker-compose.yml it works ??
Why is that?
Seems it interferes with some other container from another build, does docker-compose not seperate the containers between different docker-compose.yml?

2
Can you add the result of "ls -l code/dist"? - Adrian Mouat
Also, why not use the Nginx official image? - Adrian Mouat
code/dist is basically just index.html. i tried with the official image but switched back to a container that did work here, just to avoid misconfiguration - ivoba
i at least made it work now, but another questions arose, see the update - ivoba
@ivoba -- Regarding the interference between different docker-compose setups, there is caching that docker-compose does, so this might cause what you're seeing, but I'm just guessing with my limited Docker knowledge. The caching can be disabled when building with docker-compose build --no-cache, so you could test this to see if it helps. - Dolan Antenucci

2 Answers

0
votes

Looking at the error, nginx is trying to fetch index.html from /var/www/web/index.html. However, you are mounting the code to var/www. I figure the container nginx might be using an earlier build that uses the /var/www/web/ directory and changing the container name forced a rebuild. docker-compose up --build should force a rebuild.

0
votes

the problem is your line

- code/dist:/var/www

if you change it to

- ./code/dist:/var/www

everything should be fine.