Trying to run a scratch container (as a step) (no shell in the container)

I’m trying to run the container scanner image anchore/grype as a step, like this:

steps:
  - name: grype
    image: anchore/grype
    commands:
      - /grype foo

It always exits with exit code 127. I looked at the pod; and its trying to run as script.

DRONE_SCRIPT:

                                   if [ ! -z "${DRONE_NETRC_FILE}" ]; then
                                     echo $DRONE_NETRC_FILE > $HOME/.netrc
                                     chmod 600 $HOME/.netrc
                                   fi

                                   unset DRONE_SCRIPT
                                   unset DRONE_NETRC_MACHINE
                                   unset DRONE_NETRC_USERNAME
                                   unset DRONE_NETRC_PASSWORD
                                   unset DRONE_NETRC_FILE

                                   set -e

                                   remote_debug() {
                                     if [ "$?" -ne "0" ]; then
                                       /usr/drone/bin/tmate -F
                                     fi
                                   }

                                   if [ ! -z "${DRONE_TMATE_HOST}" ]; then
                                     echo "set -g tmate-server-host $DRONE_TMATE_HOST" >> $HOME/.tmate.conf
                                     echo "set -g tmate-server-port $DRONE_TMATE_PORT" >> $HOME/.tmate.conf
                                     echo "set -g tmate-server-rsa-fingerprint $DRONE_TMATE_FINGERPRINT_RSA" >> $HOME/.tmate.conf
                                     echo "set -g tmate-server-ed25519-fingerprint $DRONE_TMATE_FINGERPRINT_ED25519" >> $HOME/.tmate.conf
                                   fi

                                   if [ "${DRONE_BUILD_DEBUG}" = "true" ]; then
                                     trap remote_debug EXIT
                                   fi


                                   echo + "/grype foo"
                                   /grype foo

But there is no shell to do this? How do you make this work?

I’ve tried using entrypoint with no luck either.

You can use entrypoint and command (you must remove the commands attribute)

steps:
  - name: grype
    image: anchore/grype
    entrypoint: [ /grype ]
    command: [ foo ]
1 Like