Running executable from /opt/

I’m still a beginner, and not using Docker in the traditional way I guess. I’m trying to create an image for launching a processing engine (doesn’t really matter what it does here).

Here’s my Dockerfile:

FROM ubuntu:18.04


COPY mypackage_23.0.1.2755-1_x64.deb ./

RUN bash -c 'apt update'
RUN bash -c 'apt -y install ./mypackage_23.0.1.2755-1_x64.deb'

# export some environment variables for licensing purposes
# and some settings irrelevant here

CMD ['/opt/mypackage/bin/myEngine']  # Launch a process that will run undefinitely

When running the image in a container, this is what I’m getting:
2023-09-06 16:51:16 /bin/sh: 1: [/opt/mypackage/bin/myEngine]: not found

Using Docker Desktop, I can check the file exists with the Files tab (see screenshot).

I also tried to add a symlink in /usr/bin and using the symlink:

# ...
RUN bash -c 'ln -s /opt/mypackage/bin/myEngine /usr/bin/myEngine'

CMD ['myEngine']

and this is the result:
2023-09-06 16:56:37 /bin/sh: 1: [myEngine]: not found

Once again, using the Files tab, I double checked the symlink existed, and targetted the correct path.

My question is: how can I run the executable using Dockerfile? Thanks

The problem is probably the content of myEngine. Make sure it has line breaks as Linux expects it. LF (line feed) and not CRLF (Carriage return + line feed) which is for Windows.

Is that file created by the deb package? If it is, who created that package?

Some other recommendations unrelated to your issue:

You probably don’t need bash to run apt update and it should be apt-get update in the same instruction where you run the install command.

RUN apt-get update \
 && apt-get install -y ./mypackage_23.0.1.2755-1_x64.deb

You need a bash shell only if you want to use features that works only in a bash shell. Regarding apt, as far as I know apt is still not stable and not recommended to run it in a script. Not to mention that you are using an old LTS :slight_smile: Again, this is not related to your original issue.

myEngine is a binary file. It is created by the .deb package, which is created by my company. As far as I know, everything is compiled on Ubuntu 18.04 LTS (thus why I’m using the same version), so I don’t think bad line ending applies.

Thanks for the tips, I’ll try them even if it doesn’t solve the main issue.

Okay, you were right. The issue is usually what I mentioned, but in this case after I tried, I realized the problem is that you are using single quotes. Try it with double quotes:

CMD ["/opt/mypackage/bin/myEngine"]

A little explanation: The syntax of the CMD is json and in json quotes are double quotes.

1 Like

Thanks, that was the issue!