Reputation: 1934
I want to install an application that requires a Java SDK to be installed, but I don't want to install Java on my computer. Instead I would like to install Java to a Docker container and allow apps on my host machine to use it.
Is this possible?
Upvotes: 0
Views: 223
Reputation: 158705
Docker doesn’t really work that way. It’s best for packaged complete applications that you can access via a network connection; in the Java case, a JRE plus an app server plus an installed application would make a reasonable complete image.
It’s possible to share files between the host and a container, but mostly that direction is “push things into a container”. In your example you could use the docker run -v
option to push your source directory into the container, but you’d have to actually run the JDK commands (javac
, mvn
, ...) from inside the container. You can use docker exec
to do this, but it’s an unnatural workflow IMHO, and it requires you to have administrator-level privileges to do even routine things.
I’d put the JDK and the application in the same place: either bundle both into a single Docker image, or install the JDK on your host.
Upvotes: 1