1

I have NGINX set up on Centos 7.5, listening on port 80, and directing the traffic to a Gunicorn server. That is the main purpose of this server, and these are are locally installed applications, no containers so far.

Now, I would like to run some services within Docker containers, and have different subdomains (or perhaps ports) redirect the traffic to the relevant containers.

A specific example - SVN server

I'm very new to the whole Docker concept, and the lack of specific documentation for some containers really confuses me. I managed to make some progress with this SVN server container. This is the command I use: docker run -d --name svn-server -p 80:80 -p 3960:3960 -v /home/svn:/home/svn elleflorio/svn-server

This is what I have so far:

  • The SVN server is accessible via http://mysite/svn (port 80).
  • The container binds successfully to the local directory, keeping the repository data even if the container is deleted, which is great.
  • I can run commands within the container, create users, add repositories.

These are the problems:

  • I had to stop NGINX, since it also needs port 80.
  • No success so far in getting the container to run on a different port, it didn't work when I simply tried to change the -p parameter; I tried temporarily disabling SELinux which didn't help.
  • If I could run the container on a different port, I could redirect traffic from a subdomain to that port, but I'm sure there's a better practice for working with Docker containers.
  • If I manage to get this to work - how do I make sure the container is restarted upon host reboot?
2
  • Not sure about the Docker part, but the question's title asks for an ordinary "reverse proxy" Nginx config. Commented Oct 31, 2018 at 10:34
  • @grawity, I'm not very fluent with the jargon. I am somewhat familiar with the phrase but wasn't sure it was appropriate here.
    – Shovalt
    Commented Oct 31, 2018 at 14:27

1 Answer 1

0

To make your container use port 8080 instead of its published port 80, use docker run ... -p 8080:80 .... The first number is the port that you can connect to on the host, while the second is the "native" port on the container. This {host}:{container} convention is used elsewhere.

Make sure you have stopped the current container (docker ps to list running containers), otherwise you will have a lingering container using port 80.

To restart the container on boot, you can make a systemd service that does a docker run ....

3
  • Could you please explain the -p [port1]:[port2] annotation? Does the first refer to the host and the second to the container?
    – Shovalt
    Commented Oct 31, 2018 at 11:42
  • Yes, the first number is the port that you can connect to on the host, while the second is the "native" port on the container. This {host}:{container} convention is used elsewhere (volumes...).
    – xenoid
    Commented Oct 31, 2018 at 13:52
  • Thanks @xenoid, this works. I added your comment to the answer itself.
    – Shovalt
    Commented Oct 31, 2018 at 14:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .