How to settings maximal file descriptor e.g using ulimit ?

I have concurrent proccess that’s need to open many file, and send them trough tcp using golang, but when I run the code, it say:

xxxxxx socket: too many open files.

Since your code runs in a VM, you can set this by wrapping your app with a shell script in which you set these values with ulimit. Are you using a Dockerfile?

I was just trying this out on a Fly application built and deployed with docker and was unable to update the file descriptors. In my entrypoint file I attempt the following:

ulimit -n 20000

But I receive the following error:

2022-10-27T17:31:40Z   [info]/opt/conductor/bin/start: line 4: ulimit: open files: cannot modify limit: Operation not permitted

Any ideas on how to accomplish this? Our application has thousands of concurrent websocket connections.