Skip to content

Compose.pull() fails when a service doesn't provide an 'image' property #42

@loriswit

Description

@loriswit

I have the following compose file:

services:
  web:
    build: .
    ports:
      - "8000:8000"
    environment:
      DB_HOST: db
  db:
    image: "postgres"
    environment:
      POSTGRES_PASSWORD: postgres

Running compose.pull() triggers the following error:

node_modules/dockerode/lib/util.js:48
  var digestPos = input.indexOf('@');
                        ^

TypeError: Cannot read properties of undefined (reading 'indexOf')
    at module.exports.parseRepositoryTag (node_modules/dockerode/lib/util.js:48:25)
    at Docker.pull (node_modules/dockerode/lib/docker.js:1457:23)
    at Compose.pull (node_modules/dockerode-compose/compose.js:69:41)

I suspect this is related to this piece of code:

async pull(serviceN, options) {
options = options || {};
var streams = [];
var serviceNames = (serviceN === undefined || serviceN === null) ? tools.sortServices(this.recipe) : [serviceN];
for (var serviceName of serviceNames) {
var service = this.recipe.services[serviceName];
try {
var streami = await this.docker.pull(service.image);

At line 69, the code assumes there's always an image property in the service. However, as shown in my compose file, there's no such property in the web service.

This should be easily fixable by skipping services that don't provide an image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions