code: def create_docker_credentials_file(
          username,
          password,
          file_name='docker.tar.gz'):
      
  
      import base64
      auth_hash = base64.b64encode(
          '{}:{}'.format(username, password).encode()).decode()
  
      config_json = {
          "auths": {
              "https://index.docker.io/v1/": {"auth": auth_hash}
          }
      }
  
      config_json_filename = 'config.json'
      # Write config.json to file
      with open(config_json_filename, 'w') as f:
          json.dump(config_json, f, indent=4)
  
      try:
          # Create a docker.tar.gz
          import tarfile
          with tarfile.open(file_name, 'w:gz') as tar:
              tar.add(config_json_filename, arcname='.docker/config.json')
              tar.close()
      except Exception as e:
          print('Failed to create a docker credentils file {}'.format(e))
          raise e
      finally:
          os.remove(config_json_filename)
docs: Create a docker credentials file.
          Docker username and password are used to create a `{file_name}`
          with `.docker/config.json` containing the credentials.
  
          :param username: docker username
          :type username: str
          :param password: docker password
          :type password: str
          :param file_name: credentials file name `docker.tar.gz` by default
          :type file_name: str