RestTemplate exchange call gives 503 error when running in Docker container at Kubernetes environment

My Spring Boot application runs fine when I run on the server as traditional way.
But, when I create a Docker image with this app and run the container at Kubernetes environment, I get “503 Service Unavailable” error back when the app makes RestTemplate call.

Here is the code snipped where the call is made:

  • Avoid hard coding the mysql container ip in my apache container script
  • Why is Jenkins on the docker host responding to HTTP requests from inside containers?
  • Docker not working on Windows 10
  • docker restart on cascade
  • 'make' command not found in docker container
  • How to mount docker volume with jenkins docker container?
  • import org.springframework.core.ParameterizedTypeReference;
    import org.springframework.http.HttpEntity;
    import org.springframework.http.HttpHeaders;
    import org.springframework.http.HttpMethod;
    import org.springframework.http.ResponseEntity;
    import org.springframework.web.client.RestTemplate;
    private boolean isActiveUserExist(String userId, String password) {
        String restUrl = "";
        HttpHeaders headers = new HttpHeaders();
        headers.add("Authorization", "Basic "+ Utils.base64Creds(userId, password));
        HttpEntity<String> request = new HttpEntity<String>(headers);
        //construct the URL with Request Parameters parameters    
        try {
          restUrl = restUrl + "?userId=" +, "UTF-8");
        } catch (UnsupportedEncodingException e) {
          throw e;
        restUrl = restUrl + "&applicationPk=1"; //primarykey for this app
        log.debug("Rest URL to check user <{}>.", restUrl);
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<Person> response = null;
          response =, HttpMethod.GET, request, 
              new ParameterizedTypeReference<Person>() {
        } catch (Exception e) {
          log.error("Rest URL to check user returns error {}.", e.getMessage());
          throw e;
        Person person = response.getBody();
        log.debug("isActiveUserExist({}) returns: {}",userId,person);
        return  ( person != null ) ;

    Do you see any reason why call would not work and return 503 when it runs in the Docker Container at Kubernetes?

  • Docker compose not exposing port for application container
  • Image not pulled in systemd ExecStartPre=
  • Bash Command Templating For Docker
  • Docker container not starting when connect to postgresql external
  • How to send requests to a web server running inside a docker container inside an AWS EC2 machine from the outside world?
  • Docker memory leak with sonarqube
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.