diff --git a/README.md b/README.md index 9fa96a0..8284fdf 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ $ portainer image-list | jq "[.[] | {id: .Id, image: .Image}]" | prettyoutput Example of a web application using a redis database : ```sh -$ portainer container-deploy my.private-registry.io/my-image:0.0.1 my-container \    master  +$ portainer container-deploy my-image:0.0.1 my-container \    master  --registry 'my.private-registry.io' \ --hostConfig '{ "Links": ["redis-server:redis"], "RestartPolicy": { "Name": "unless-stopped" } }' \ --env '["APP_ENV=staging", "REDIS_HOST=redis"]' \ @@ -142,7 +142,7 @@ Some environment variables are supported by the command to override settings, or - PORTAINER_JWT : portainer JWT token (obtained in authentication result, and usually available for 8 hours) - PORTAINER_USERNAME : username of the portainer account to use when an authentication is needed (to generate a new JWT) - PORTAINER_PASSWORD : password of the portainer account to use when an authentication is needed (to generate a new JWT) -- PORTAINER_REGISTRY_SERVER : docker private registry server hostname +- PORTAINER_DOCKER_REGISTRY : docker registry server hostname - ENCRYPTION_KEY : encryption key to use to encrypt / decrypt passwords saved in settings file - LOG_LEVEL : log level - LANG : preferred lang to use (aliases : LC_ALL, LC_MESSAGES, LANGUAGE) @@ -241,7 +241,7 @@ Set portainer host options. - params : - from : string - - registryAuth? : string + - registry? : string - data? : any - query? : any - headers? : any diff --git a/src/main/api/docker-api-client.ts b/src/main/api/docker-api-client.ts index d14c9f7..ae895f4 100644 --- a/src/main/api/docker-api-client.ts +++ b/src/main/api/docker-api-client.ts @@ -1,4 +1,5 @@ import { Options } from 'got' +import { compact } from 'lodash' import { ApiClientParams, DockerApiClientable, @@ -80,7 +81,10 @@ class DockerApiClient implements DockerApiClientable { const qs = { ...params.query } const headers = { ...params.headers } if (params.from) { - Object.assign(qs, { fromImage: params.from }) + const fromImage = compact( + (params.registry ? params.registry.split('/') : []).concat(params.from.split('/')), + ).join('/') + Object.assign(qs, { fromImage }) } if (params.registry) { Object.assign(headers, { diff --git a/src/main/cli/commands/container/deploy.ts b/src/main/cli/commands/container/deploy.ts index b4c9067..ed96a8b 100644 --- a/src/main/cli/commands/container/deploy.ts +++ b/src/main/cli/commands/container/deploy.ts @@ -30,7 +30,7 @@ const dockerStartContainer: CommandSpecFactory = (portainer: PortainerApiClienta alias: 'r', type: 'string', description: __('Docker registry server'), - default: process.env.PORTAINER_REGISTRY_SERVER, + default: process.env.PORTAINER_DOCKER_REGISTRY, }, }) return args diff --git a/src/main/cli/commands/image/create.ts b/src/main/cli/commands/image/create.ts index 1348cb9..08572ac 100644 --- a/src/main/cli/commands/image/create.ts +++ b/src/main/cli/commands/image/create.ts @@ -16,7 +16,7 @@ const dockerCreateImage: CommandSpecFactory = (portainer: PortainerApiClientable alias: 'r', type: 'string', description: __('Docker registry server'), - default: process.env.PORTAINER_REGISTRY_SERVER, + default: process.env.PORTAINER_DOCKER_REGISTRY, }, }) return args diff --git a/src/main/types/docker-api-client.d.ts b/src/main/types/docker-api-client.d.ts index 0e542d2..3391004 100644 --- a/src/main/types/docker-api-client.d.ts +++ b/src/main/types/docker-api-client.d.ts @@ -25,7 +25,7 @@ export interface DockerApiClientable { env?: any } & ApiClientParams, ): Promise - createImage(params: { from: string; registryAuth?: string } & ApiClientParams): Promise + createImage(params: { from: string; registry?: string } & ApiClientParams): Promise deployContainer( params: { image: string