Curl to HTTPS request is not working in docker container

We have an issue with docker swarm networking. When we are sending POST request using curl request it was working fine from host server but not from inside the container.

  • Issue type: Bug
  • OS Version/build: Rocky Linux 8.7 (Green Obsidian)
  • Docker version: 20.10.12
  • Steps to reproduce:
    - Install docker and enable swarm node.
    - Deploy nginx stack.
    - Run below curl request from inside the nginx stack:
    curl --location --request POST 'https://api.surepay.io/oauth/client_credential/accesstoken' --header 'Authorization: Basic 12345==' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials'
    Expected result: {“fault”:{“faultstring”:“Failed to resolve API Key variable oauthv2accesstoken.GenerateAccessTokenClient.client_id”,“detail”:{“errorcode”:“steps.oauth.v2.FailedToResolveAPIKey”}}}
    Actual result: curl: (35) OpenSSL SSL_connect: Connection reset by peer.
    - Try same from host machine and will get correct response

Please see the image:

Can anyone help what’s needs to change to make this working ?

This issue has resolved after recreating docker gateway network with MTU 1400 as our host server is using MTU 1400 but in docker default it is 1500.