<p>I am fairly new to this, I don't know if I am heading in the right direction or not. I have a custom nginx.conf that works fine, I am now trying to build a docker image with it so that I can run it as a container in kuberentes. </p>

<p>Here is my nginx.conf</p>

<pre><code>user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}


stream {
    #define the various upstreams
    upstream app_1 {
        server 192.168.122.206:5678;
    }

    upstream app_2 {
        server 192.168.122.206:9000;
    }   
    #map source port to upstream
    map $remote_port $backend_svr {
        1234 "app_1";
        1235 "app_2";
    }
    #all udp traffic received on 8000, depending on source it will be redirected
    server {
        listen 8000 udp;
        proxy_pass $backend_svr;
    }

}
</code></pre>

<p>On my virtual machine I have /home/asvilla/docker-files/nginx-udp/Dockerfile  which contains </p>

<pre><code>FROM nginx
RUN chmod +w /etc/nginx/nginx.conf
COPY nginx.conf /etc/nginx/nginx.conf
RUN cat /etc/nginx/nginx.conf
</code></pre>

<p>I build it using </p>

<pre><code>docker build -t "custom_nginx:dockerfile" .
</code></pre>

<p>The nginx container should redirect udp traffic incoming on port 8000 to either port 5678 or port 9000 depending on the source of the udp packet. </p>

<p>I run with docker run 'image-id' but it doesn't function as expected. Running docker ps shows "PORTS   80/tcp "
and "COMMAND  nginx-g daemon of ..."</p>

<p>Any pointers on what these mean. nginx by default binds tcp to port 80 but I have changed the nginx.conf, the cat command I run shows that the file is updated. </p>

<p>I am assuming that I have to expose the ports in the nginx.conf somehow. Any help much appreciated.</p>

alexv9
<p>You must publish the port at runtime like this:
<code>docker run -p 8000:8000 image-id</code>.</p>
