It says "in container #: image is required" while the image was set

I have setup my CircleCI 2.0 config file as:

# Javascript Node CircleCI 2.0 configuration file
# .circleci/config.yml
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
version: 2

workflows:
  version: 2
  test:
    jobs:
      # https://discuss.circleci.com/t/run-tests-on-multiple-versions-of-python/15462/2
      - test-latest
      - test-LTS
      # Wikimedia Tool Labs: v0.10.25
      - test-0.10

# a collection of steps
jobs:
  test-LTS: &test-template
    docker:
      # https://circleci.com/docs/2.0/circleci-images/
      # https://github.com/CircleCI-Public/circleci-dockerfiles/tree/master/node/images
      - image: circleci/node:10.9.0-stretch
    steps:
      - checkout
      - run: # run tests
          name: test
          command: npm test

  test-latest:
    <<: *test-template
    docker:
      - image: circleci/node:11.8.0-stretch

    working_directory: ~/repo

    steps:
      - checkout
      - run:
          name: update-npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache: # special step to restore the dependency cache
          # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: install-npm-wee
          command: npm install
      - save_cache: # special step to save the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run: # run tests
          name: test
          command: npm test

  test-0.10:
    <<: *test-template
    docker:
      - image: circleci/node:4.8.7
      # https://discuss.circleci.com/t/how-to-change-node-version-in-circleci-2-0/17455/2
      - run:
          name: Install node@0.10.25
          command: |
            set +e             
            touch $BASH_ENV  
            curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
            echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
            echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
            echo 'nvm install v0.10.25' >> $BASH_ENV
            echo 'nvm alias default node' >> $BASH_ENV

But it says “in container #: image is required” for all 3 tests.

I think there are errors in the config file but I can’t identify it. What should I do to correct the errors?

Hello @kanasimi

It looks as if you are injecting the docker key twice.

Your &test-template contains the docker key, along with an image.

And then in the next job (and the other) you reference this image and include another:

  test-latest:
    <<: *test-template
    docker:
      - image: circleci/node:11.8.0-stretch

should expand to:

  test-latest:
    docker:
      - image: circleci/node:10.9.0-stretch
    steps:
      - checkout
      - run: # run tests
          name: test
          command: npm test
    docker:
      - image: circleci/node:11.8.0-stretch

Thank you.
I give up to use " <<: *test-template" and than it is OK now.

1 Like