Average Bear
Average Bear

Reputation: 201

Docker CMD or RUN using JIB build

I need to create a custom image based on Ubuntu that contains software that I need to install using apt. For example:

sudo apt-get install pcscd 
sudo apt-get install pcsc-tools # same as pcsc-lite   

# For OMNIKEY for driver Then unpack the file and run the installer:
cd /home/cccam/ifdokccid_lnx_x64-3.7.0/ 
chmod 755 install
sudo ./install

And I also want the software to run under OpenJDK 1.8 64 bit which I will also install. The point is I need to run commands like these. How can I do this with JIB? Is there a way to get JIB to use a Docker File? Is there any way to pass a script of commands like this into JIB?

Upvotes: 7

Views: 8867

Answers (1)

Chanseok Oh
Chanseok Oh

Reputation: 4306

Jib does not use Dockerfile (and it works even without Docker installed); the way Jib builds an image is fundamentally different from how the Docker CLI builds an image using Dockerfile (reproducible vs. non-reproducible, declarative vs. imperative, Docker and Dockerfile-less build vs. requiring Docker daemon and client, requiring root-privilege vs. not). Basically, Jib doesn't "run" Dockerfile directives, particularly the ones like RUN that executes something; Jib doesn't provide/include a Docker runtime (that is one of the points of Jib).

For installing complex software packages like OpenJDK, the best option (for now) is to prepare a custom base image that comes with all those packages pre-installed and have Jib use that image. Note recent Jib versions can specify a local Docker daemon image or a tarball as a base image (in addition to a remote registry image).

If you just need to install a small number of binaries, you can copy arbitrary files with the extraDirectories feature (Maven / Gradle). Here is an example that installs a Stackdriver Debugger Java agent using the feature.

Just in case, you can configure Jib to run arbitrary ENTRYPOINT or CMD, or include custom script files (using the extraDirectories feature) and run them at runtime, but I don't really think you are asking this capability. I believe your goal is to install extra software packages at build time.

Upvotes: 12

Related Questions