sophie-germain
sophie-germain

Reputation: 981

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.

Upvotes: 19

Views: 72175

Answers (3)

Tomas Tomecek
Tomas Tomecek

Reputation: 6456

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.

Upvotes: 21

Ofir Petrushka
Ofir Petrushka

Reputation: 51

Basically the "add" command copies a file from your local system into the docker image.

See here for more: https://docs.docker.com/reference/builder/#add

Upvotes: 2

szefuf
szefuf

Reputation: 520

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

Upvotes: 3

Related Questions