Welcome! Log In Create A New Profile

Advanced

Migrating existing Nginx to Docker

Posted by raphattack 
Migrating existing Nginx to Docker
October 08, 2019 05:48PM
I have Nginx up and running on my server and everything works well. I am trying to migrate over to run Nginx in a Docker container.

I have copied all files in:
- /etc/nginx to /home/raphattack/docker/nginx/etc
- /usr/share/nginx to /home/raphattack/docker/nginx/share

I am using the following command to run the Docker image:
sudo docker run --detach \
--name nginx \
--publish 80:80 \
--publish 443:443 \
--volume /home/raphattack/docker/nginx/etc:/etc/nginx \
--volume /home/raphattack/docker/nginx/share:/usr/share/nginx \
nginx

This fails with the error:
2019/10/08 21:18:58 [emerg] 1#1: open() "/etc/nginx/modules-enabled/50-mod-http-geoip.conf" failed (2: No such file or directory) in /etc/nginx/nginx.conf:4
nginx: [emerg] open() "/etc/nginx/modules-enabled/50-mod-http-geoip.conf" failed (2: No such file or directory) in /etc/nginx/nginx.conf:4

Line 4 in my nginx.conf:
include /etc/nginx/modules-enabled/*.conf;

The file in question is a symlink:
/etc/nginx/modules-enabled/50-mod-http-geoip.conf -> /usr/share/nginx/modules-available/mod-http-geoip.conf
Re: Migrating existing Nginx to Docker
October 15, 2019 09:06AM
The symlink is interpreted inside the container, not on the host system. The modules referred to should be compatible with the version of the operating system inside the container and have to refer to a valid location there. I assume /usr/share/nginx is the location on the Docker host system.

Another comment: I would also map /var/log/nginx into the container, so logs won't be lost when the container is restarted.

--j.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 78
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready