When use multiple images the second one commands isn't accessible

I have this yml:

 jobs:
     deploy_to_staging:
         docker:
           - image: google / cloud-sdk
           - image: circleci / openjdk: 11-jdk

I have access to commands only from the first image, for example when the command gradle build runs it returns:

 / bin / bash: gradle: command not found

If I invert image order then I can access gradle commands but gcloud will not be found.

Does anyone know which is my mistake?

1 Like

@felipeespitalher a similar situation has been addressed in this previous post

I would install the gcloud client in the circleci/openjdk:11-jdk image in the pipeline and eliminate the google/cloud-sdk image. Below is an example of how to do this:

curl -o gcp-cli.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz
tar -xzvf gcp-cli.tar.gz
echo ${GOOGLE_CLOUD_KEYS} | base64 --decode --ignore-garbage > ${HOME}/.ssh/cicd_demo_gcp_creds.json
./google-cloud-sdk/install.sh  --quiet
echo 'export PATH=$PATH:~/google-cloud-sdk/bin' >> $BASH_ENV
source $BASH_ENV
gcloud auth activate-service-account --key-file ${HOME}/.ssh/cicd_demo_gcp_creds.json

You could also use the gcloud CirlcleCI orbs to install the client as well.

Anybody other suggestions here? I’m also running into the same issue. I don’t have access to commands from images that are no in the first listed image.

Here is my executor:

  node-pg-cypress-executor:
    docker:
      - image: cypress/base:12
      - image: cimg/node:15.11.0
      - image: circleci/postgres:9.6.2-alpine

I’ve removed the environment keys from all images.

When cypress does not come first I fail with missing cypress-specific sub-dependencies.
When node does not come first I fail on not having sudo installed, which is being used by one of the commands.

Any help is super appreciated.

The first image is your execution image. All commands run there. The other images are only available via TCP/IP networking.

1 Like

Thank you @FelicianoTech! :raised_hands: I did get it to work and your explanation makes sense as to why it works as is now :slight_smile:

1 Like