ealeon
ealeon

Reputation: 12462

Dockerfile: command not found

What the docker image should run:

-bash-4.2$ pwd
/u/workspaces/compose/src

-bash-4.2$ ls
compileAndTest 

-bash-4.2$ vim compileAndTest
#!/usr/bin/env bash

echo 'hi'

Dockerfile

-bash-4.2$ pwd
/u/mybuild

-bash-4.2$ ls
Dockerfile

-bash-4.2$ vim Dockerfile
FROM java
WORKDIR /u/workspaces/compose
CMD /src/compileAndTest

build and run

-bash-4.2$ docker build -t myjavabuild .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM java
 ---> 69a777edb6dc
Step 2 : WORKDIR /u/eugenep/workspaces/compose
 ---> Using cache
 ---> 583d8616f495
Step 3 : CMD /src/compileAndTest
 ---> Using cache
 ---> d0458943d19e
Successfully built d0458943d19e
-bash-4.2$ docker run myjavabuild
/bin/sh: 1: /src/compileAndTest: not found

even though the path to the executable compileAndTest is specified in Dockerfile, it says not found

anyone know why?

Upvotes: 1

Views: 7798

Answers (2)

diamond
diamond

Reputation: 171

Add compileAndTest file from host machine is missing.

Upvotes: 1

JesusTinoco
JesusTinoco

Reputation: 11828

The problem here is that you are not copying the /src/compileAndTest file to the filesystem of the container. You could use the ADD tag in the Dockerfile to achieve that.

FROM java
WORKDIR /u/workspaces/compose
ADD /u/workspaces/compose/src/compileAndTest /src/compileAndTest
RUN chmod +x /src/compileAndTest
CMD /src/compileAndTest

Upvotes: 1

Related Questions