Reputation: 980
I'm trying to setup an nginx container via docker-compose. I have a custom configuration I'd like to use. I make the config available on a volume that is shared with the container.
nginx:
volumes:
- shared:/shared
image: nginx
ports:
- "8080:80"
- "443:443"
command: /bin/bash -c ./shared/nginx_test.conf
Here is the configuration file:
daemon off;
http {
server {
location / {
root /shared/data/www;
}
location /images/ {
root /data;
}
}
}
When I do a docker-compose up, I get errors for each line in the config that say the command is not found. e.g. ./shared/nginx_test.conf: line 1: daemon: command not found
, ./shared/nginx_test.conf: line 3: http: command not found
and so on.
I tried following the guide here. Any ideas on why the commands are not found by nginx?
Upvotes: 1
Views: 1359
Reputation: 16677
You're trying to run a script file with bash -c
, do you see that? That's not what you want. (The error messages say the content of ./shared/nginx_test.conf
is not understood, which Bash interprets as terminal commands.)
You probably want to run something like nginx -g daemon off
as a command, and append the configuration file as an argument:
nginx:
# ...
command: nginx -c ./shared/nginx_test.conf -g "daemon off;"
References:
Upvotes: 3