I am not sure why I expected this to work:
# Dockerfile
FROM node:6
FROM java:8
but it doesn't really work - looks like the first command is ignored, and second command works.
Is there a straightforward way to install both Node.js and Java in a Docker container?
Ultimately the problem I am trying to solve is that I am getting an ENOENT error when running Selenium Webdriver -
[20:38:50] W/start - Selenium Standalone server encountered an error: Error: spawn java ENOENT
And right now I assume it's because Java is not installed in the container.
It's ok to have multiple processes, but to get the most benefit out of Docker, avoid one container being responsible for multiple aspects of your overall application. You can connect multiple containers using user-defined networks and shared volumes.
Using the docker-compose CLI command, you can create and start one or more containers for each dependency with a single command (docker-compose up).
Docker Compose is a tool that helps us overcome this problem and efficiently handle multiple containers at once. Also used to manage several containers at the same time for the same application. This tool can become very powerful and allow you to deploy applications with complex architectures very quickly.
The best way for you is to take java (which is officially deprecated and it suggests you use openjdk
image) and install node in it.
So, start with
FROM openjdk:latest
This will use the latest openjdk image, which is 8u151
at this time. Then install node
and other dependencies you might need:
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
You might want to install things like grunt afterwards, so this might come in handy as well.
RUN npm install -g grunt grunt-cli
In total you will get the following Dockerfile:
FROM openjdk:latest
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh \
RUN npm install -g grunt grunt-cli
You may clone the Dockerfile from my gitlab repo here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With