1.0.4 • Published 3 years ago

docker-ssh-http-agent v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

Docker SSH HTTP Agent

Create an http agent that connects to a remote docker instance over SSH.

Native usage

const fs = require('fs');
const path = require('path');
const http = require('http');

const agent = require('docker-ssh-http-agent')({
  host: '192.168.1.1',
  port: 22,
  username: 'root',
  privateKey: fs.readFileSync(path.resolve(process.env.HOME, '.ssh/id_rsa'))
});

const request = http.request({
  socketPath: '/var/run/docker.sock',
  path: `/v1.26/containers/json`,
  agent
}, function (response) {
  response.on('data', chunk => {
    console.log(chunk.toString())
  })
})
request.end()

3rd Party usage (with axios)

const fs = require('fs');
const path = require('path');
const axios = require('axios');

const agent = require('docker-ssh-http-agent')({
  host: '192.168.1.1',
  port: 22,
  username: 'root',
  privateKey: fs.readFileSync(path.resolve(process.env.HOME, '.ssh/id_rsa'))
});

const request = axios({
  url: '/v1.26/containers/json',
  httpAgent: agent
}).then(response => {
  console.log(response.data)
});
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago