Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running an executable in a dockerfile

I am new to Docker and am reading through The Docker Book by Turnbull. Essentially, I have a grasp of the terms and process of how containers work and how images work in Transmission Protocol and virtualized operating systems.

however, my dockerfile is not running an executable which is local, and I can not figure out how to add my local executable into my container's /bin directory.

My goal: I would like to add name.exe into the /bin directory of my container. Then I would like to have a docker file that is

FROM ubuntu
MAINTAINER [email protected]
RUN ["name.exe", "input1", "output"]

and have my container run my program, and create an output. My goal is to them put my container onto my repo, and share it, along with all of the /bin programs I have written.

However, I am not able to do so.

like image 665
sophie-germain Avatar asked Mar 27 '15 01:03

sophie-germain


2 Answers

Bear in mind that name.exe have to be in same directory as your dockerfile. From the documentation:

The <src> path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.

Your dockerfile could look like this then:

FROM ubuntu
MAINTAINER [email protected]
COPY name.exe /bin/
CMD ["/bin/name.exe", "input1", "output"]

You can build it then like this:

docker build --tag=me/my-image .

And when you run it (docker run me/my-image), it will run /bin/name.exe input1 output.

like image 148
Tomas Tomecek Avatar answered Oct 24 '22 09:10

Tomas Tomecek


Try:

FROM ubuntu
ADD name.exe /bin/name.exe
ENTRYPOINT["name.exe"]
CMD["input1","input2"]

But this input1 input2 have to be on docker too, otherwise you have to add -v when running

like image 44
szefuf Avatar answered Oct 24 '22 09:10

szefuf