Here is a `Dockerfile` that will install Python `3.8` (latest) on a docker image based on the `rocker/r-ver:3.5.1` docker image. I `piped` the output of some of the build commands to `/dev/null`to reduce the output.
You can change the ARG `PYTHON_VER` value to `3.6` if you want Python `3.6` instead.
Using the new Buildkit build enhancements available in Docker EE 18.09 I was able to reduce the build time down from 3m16.401s to 2m32.925s.
Buildkit is experimental and is only supported on Docker Linux engines. You must set "experimental" mode in the Docker daemon and your client. It has some performance improvements and some other "experimental" functions.