docker-modem
docker-modem copied to clipboard
Add pathPrefix option
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
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>'
});