0
我的問題是如何能夠連接到碼頭集裝箱內的碼頭機插座?如何從碼頭集裝箱到碼頭機器進行通信?
我想達到什麼是dockerize一個API網關,但這個API網關需要傳達給泊塢窗機插座,要能夠發現類似如下的運行容器:
const machine = process.env.DOCKER_HOST
const tls = process.env.DOCKER_TLS_VERIFY
const certDir = process.env.DOCKER_CERT_PATH
if (!machine) {
throw new Error('You must set the DOCKER_HOST environment variable')
}
if (tls === 1) {
throw new Error('When using DOCKER_TLS_VERIFY=1 you must specify the property DOCKER_CERT_PATH for certificates')
}
if (!certDir) {
throw new Error('You must set the DOCKER_CERT_PATH environment variable')
}
const dockerSettings = {
protocol: 'https',
host: machine.substr(machine.indexOf(':', 0) + 3, machine.indexOf(':', 6) - 6),
port: parseInt(machine.substr(-4), 10),
checkServerIdentity: false,
ca: fs.readFileSync(certDir + '/ca.pem'),
cert: fs.readFileSync(certDir + '/cert.pem'),
key: fs.readFileSync(certDir + '/key.pem'),
version: 'v1.25'
}
這在本地主機上運行,並且可以訪問env變量並可以訪問docker-machine套接字。
我如何溝通是從libarary dockerode
像下面
const docker = new Docker(dockerSettings)
但一旦我把它放在一個容器中需要共享這個插座與容器,以便能夠執行泊塢窗命令,這是用於在nodejs中進行一種docker服務發現。