I use an nginx reverse proxy on the same machine as the Joplin server, so in the docker-compose.yml file I map the docker container port 22300 to localhost's port 22300, thereby keeping the exposed port "within" the computer.

ports:
    - "127.0.0.1:22300:22300"

The nginx server block for the Joplin server then passes requests to 127.0.0.1:22300

location / {
       proxy_redirect off;
       proxy_pass http://127.0.0.1:22300;
    }

I have not tried it but, if your proxy server is not on the same machine or if you are not using one, I guess that you could replace 127.0.0.1 in docker-compose.yml with a static IP address for the interface on the computer that you wish to limit the connection to.