I usually ended up creating my own image containing both Python and Node with:
FROM python:3 RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - RUN apt-get install -y nodejs # ... rest of my stuff
There are two problems with this approach.
- It’s slow. Installing Node takes a while and doing it for every non-cached build is time consuming.
- You lose the Docker way of just pulling a nice prepared image. If Node changes their deployment method, the
Dockerfilehas to be updated. It’s much simpler to just
docker pull node:8
The obvious solution is going to Docker Hub and looking for an image that already contains both. There are a bunch of those but they all look sketchy and very old. I don’t feel like I can trust them to have the latest security updates, or any updates at all. When a new version of Python comes out, I can’t trust those images to get new tags with the new version which means I’d have to go looking for a new image.
So I did what any sensible person would do. I created my own (obligatory link to XKCD #927 here). But instead of creating and pushing a one-off image, I used Travis.ci to update the images daily. This was actually a pretty fun exercise that allowed me to learn more about Docker Python API, Docker Hub and Travis.ci. I tried to make it as easily extensible as possible so anyone can submit a PR for a new combo like Node and Ruby, or Python or Ruby, or Python and Java, etc.
The end result allows you to use:
docker run --rm combos/python_node:3_6 python3 -c "print('hello world')" docker run --rm combos/python_node:3_6 node -e "console.log('hello world')"
You can rest assured you will always get the latest version of Python 3 and the latest version of Node 6. The image is updated daily. And since the build process is completely transparent on Travis.ci you should be able to trust that there is no funny business in the image.