docker

2023-01-05T19:37:00.003489Z

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?

lukasz 2023-01-05T19:52:38.157909Z

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

2023-01-05T19:54:39.564299Z

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

lukasz 2023-01-05T19:57:52.112739Z

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

🔥 1
2023-01-05T20:00:21.995299Z

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

2023-01-05T20:02:16.275059Z

(I won't have brew on linux)

lukasz 2023-01-05T20:02:51.906939Z

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

lukasz 2023-01-05T20:03:44.764549Z

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

2023-01-05T20:03:47.859409Z

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

2023-01-05T20:07:19.553239Z

Thanks again

2023-01-05T20:09:33.678459Z

maybe this is a use-case for Docker compose?

lukasz 2023-01-05T20:11:37.790409Z

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

lukasz 2023-01-05T20:13:03.671769Z

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

1
2023-01-05T20:13:09.176679Z

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

2023-01-05T20:13:43.995049Z

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

2023-01-05T20:22:38.108019Z

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

2023-01-05T20:28:47.013049Z

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)

2023-01-05T20:31:40.243899Z

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

2023-01-05T20:34:27.905799Z

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

2023-01-05T22:26:00.656759Z

I made once one myself: https://hub.docker.com/r/behrica/clj-py-r

👀 1
2023-01-05T22:30:24.742899Z

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

2023-01-05T22:43:09.702819Z

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

2023-01-05T22:44:20.745069Z

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

2023-01-06T16:34:41.062189Z

The Dockerfile is here: https://github.com/behrica/clj-py-r-template/blob/master/docker-base/Dockerfile

1
2023-01-06T16:37:06.381109Z

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

2023-01-06T19:39:36.347369Z

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

gklijs 2023-02-20T22:07:51.366569Z

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

🔥 1
cap10morgan 2023-02-02T20:53:17.905929Z

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.

cap10morgan 2023-02-02T20:56:45.197049Z

along with that first FROM line that ends in AS clojure

2023-02-05T22:10:26.239389Z

cool, I'll give that a try!

👍 1