[Django]-Docker, how to expose a socket over a port for a Django Application

5👍

EXPOSE only works with UDP and TCP sockets.

If you want to make a Unix domain socket available outside of your container, you will need to mount a host directory inside the container and then place the socket there. For example, if you were to:

docker run -v /srv/webapp:/var/run/webapp ...

Then /var/run/webapp/gunicorn.sock in your container would be /srv/webapp/gunicorn.sock on your host.

Of course, this assumes that you have something running on your host, or in another container that also has access to /srv/webapp, that is able to consume that socket and use it to provide a service.

👤larsks

Leave a comment