Darksymphony
Darksymphony

Reputation: 2683

Command not found in Docker when running from Dockerfile

I am trying to build and run the docker according the Dockerfile.

The code is (before I cloned my git repo etc):

sh 'docker build -t myimage .'
sh 'docker run myimage'

The Dockerfile looks like:

FROM node:12.2.0-alpine AS build
COPY . /frontend
WORKDIR /src
CMD apt-get update
CMD gradle build

The docker build command seems to be success with result:

Successfully built 0329878899fc
Successfully tagged myimage:latest

but when executing the docker run command, it says:

    + docker run myimage
    /bin/sh: gradle: not found

ERROR: script returned exit code 127

I tried to remove CMD gradle and kept only CMD apt-get update, but then it says apt-get not found.

If I replaced CMD with RUN, then the docker build is not executed and says the same error.

Upvotes: 1

Views: 8085

Answers (1)

TheQueenIsDead
TheQueenIsDead

Reputation: 945

Apt won't be available, as you're using an alpine Linux container which uses the Apk package manager.

It seems the node image does not include Gradle by default, so you will have to install it using a RUN command.

You can do that through apt by switching to a debian based image, or by searching for the Gradle package for Alpine linux

Upvotes: 4

Related Questions