emagiz-portainer-api-client
v0.3.4
Published
Portainer API client by eMagiz
Downloads
14
Readme
Portainer API client
Example: Copy image to local registry
const portainerUrl = 'http://localhost:9000/api'
const portainerUsername = 'admin'
const portainerPassword = 'password'
const registryUrl = 'localhost:5000'
const registryUsername = ''
const registryPassword = ''
const endpointName = 'local-edge-agent'
const portainer = new PortainerClient(portainerUrl)
await portainer.authorize(portainerUsername, portainerPassword)
portainer.addRegistry(registryUrl, registryUsername, registryPassword)
await portainer.pullImage(endpointName, 'openjdk:8-jre-alpine')
await portainer.tagImage(endpointName, 'openjdk:8-jre-alpine', registryUrl + '/mirror/openjdk:8-jre-alpine')
await portainer.pushImage(endpointName, registryUrl + '/mirror/openjdk:8-jre-alpine')
await portainer.deleteImage(endpointName, registryUrl + '/mirror/openjdk:8-jre-alpine', true)
Example: Deploy a stack using compose
var compose = {
version: '3.3',
services: {
service: {
image: 'mysql',
environment: { MYSQL_ALLOW_EMPTY_PASSWORD: 'true' },
ports:['3306:3306']
}
}
}
await portainer.deployStack(endpointName, "mysql", dump(compose)) // import dump from ys-yaml
Example: Deploy a stack using compose
await portainer.deleteStack(endpointName, "mysql")
Known issues
- createContainer method does not work on most recent Portainer versions