docker-modem icon indicating copy to clipboard operation
docker-modem copied to clipboard

Add pathPrefix option

Open rumkin opened this issue 6 years ago • 1 comments

This commit add path prefix for nested HTTP APIs with customized routing. For example I can mount docker's api proxy to /system/docker/ on my server.

Also:

  • Add DOCKER_PATH_PREFIX env variable
  • Cleanup dependencies
  • Remove redundant self variable
  • Reorder dependencies

rumkin avatar Feb 20 '19 12:02 rumkin

This would be useful as well to be able to use dockerode against Portainer, which acts as a reverse-proxy to the Docker daemon's Docker Engine API (see here), but under a sub-path:
e.g. http://<portainerHost>:9000/api/endpoints/<endPointId>/docker/

So then we could do:

var docker = new Docker({
  protocol: 'http',
  host: '<portainerHost>',
  headers:{
    // previously-retrieved Portainer auth token, from the Portainer API
    Authorization: 'Bearer <jwtToken>'
  },
  port: 9000,
  // previously retrieved Portainer endpointId for the target Docker daemon, from the Portainer API
  pathPrefix: '/api/endpoints/<endPointId>'
});

arnaud-dumont-vcgs avatar Jun 04 '21 09:06 arnaud-dumont-vcgs