Docker or Docker Desktop will not “steal” your port number. It is an application issue. Your app probably has a config either in file or in a database that doesn’t set a port number so when it redirects or shows a link it will not add the port number or you just build the URL based on what port the app is listening on. If it works with an IP address, that is also probably some logic implemented in the application which we know nothing about. Sometimes localhost handled differently allowing you to access an admin page.
When you build URLs in the app , you should not assume that the port number on the client side will be the same as the port the app is listening on. The client could access the website throigh a proxy server or just forward the request from a different port like probably in your case.
If you need more help, please, share more context, how you build the URL if you developed the and how you start the container.
Use code blocks for sharing code as explained here: How to format your forum posts