Fork me on GitHub
#docker
<
2023-01-05
>
aaelony19:01:00

Hello! I have a bit of a strange question. I have a Dockerfile that starts with FROM databricks/minimal:experimental that includes installs of R and RStudio and a bunch of other things. I'd like to add a Clojure install as well. I've read that some people use multiple FROM statements, but curious what is the preferred method to include Clojure in a such Dockerfile?

lukasz19:01:38

That's the only way to do it - your Dockerfile will define a new image that will be derived from the image coming FROM ...

aaelony19:01:39

I'm a Docker beginner, does it matter which FROM... occurs first? Any relevant doc links much appreciated. Thank-you

lukasz19:01:52

I see - you'd like to merge images or something like that? That's not something you can do - I'd probably do something like this:

FROM databricks/minimal:experimental
RUN .... install clojure using one of these :  - it will depend on the OS of the base image

🔥 2
aaelony20:01:21

Thank-you, I'll try that. That looks promising

aaelony20:01:16

(I won't have brew on linux)

lukasz20:01:51

no you most likely won't, but if you figure out what is the underlying distribution you can install Java and other necessary bits to run the clojure installer

lukasz20:01:44

this might work docker run --rm -it databricks/minimal:experimental uname -a or lsb_release

aaelony20:01:47

the underlying distro will be something I choose. Probably 10.4-LTS or an LTS more recent

aaelony20:01:19

Thanks again

aaelony20:01:33

maybe this is a use-case for Docker compose?

lukasz20:01:37

That's not how Docker images work - you either start with your own base image and install whatever you need into it. Or you pick a base image which bundles some stuff already (R in your case) and then you add on top of it. You cannot really merge images using multiple FROM statements - at best you can copy files between different layers, but that's about it - so you can't pick your own base image that way

lukasz20:01:03

(to clarify: technically you can merge images, but that's just asking for trouble)

metal 2
aaelony20:01:09

got it, I appreciate the help. I'll need to read & learn more.

aaelony20:01:43

yeah - definitely not asking for trouble 😉 Something easy, solid, and painless is my preference, lol.

Carsten Behring20:01:38

Maybe you find some 'datascience' Docker image containing R plus java. Or even Clojure

aaelony20:01:47

That would be ideal. In my case, it would actually need to include databricksruntime/rbase (https://github.com/databricks/containers/blob/master/ubuntu/R/Dockerfile) plus Java and Clojure (maybe a few other things too)

aaelony20:01:40

not sure how to search for such a thing. Is this what you were thinking @U7CAHM72M? https://hub.docker.com/search?q=r+openjdk

aaelony20:01:27

this is promising:

# Example
FROM <base image>
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:11 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
from https://hub.docker.com/_/eclipse-temurin

Carsten Behring22:01:24

Your example is using a multi-stage Dockerfile. I am not sure, if this feature of Docker supports all scenarios of 'merge'

aaelony22:01:09

that is very cool, I will check it out! 🙂

aaelony22:01:20

it would be amazing to also have libpython-clj like you say. How can I peruse the Dockerfile?

Carsten Behring16:01:06

You can take and adapt it to your needs. Or copy pieces into any other Dockerfike. Of course , the instructions are working in certain base images / OS only

aaelony19:01:36

awesome, thanks. Will be teaching myself more docker foo over the weekend ;)

cap10morgan20:02:17

Man, I've done something like this before... IIRC I just needed to copy two things from the tools-deps clojure image and then I had a working clojure tools.deps system. I think I did it in a GraalVM project. Let me see if I can dig it up.

cap10morgan20:02:45

along with that first FROM line that ends in AS clojure

aaelony22:02:26

cool, I'll give that a try!

👍 2
gklijs22:02:51

Just lately learned you can copy things from one image to another. Might be helpful in reducing steps for some combined images. https://twitter.com/settermjd/status/1542086472647331840?t=Yn76fwny_wegMRTGNPCp2g&amp;s=09

🔥 2