Docker is an external program that is not connected to R in any way. You can learn about it here - https://www.docker.com/.
My first attempt would be to find a way to do it with modern versions of R or even another language (Python, for example). If that's not possible, then Docker solution might be to start a service in a container running R 3.4 and which is exposed via Plumber, for example. Then in your script you can call it as you would call any other external API.
If that sounds complicated it's because it is. Perhaps, there are easier solutions, but that's the approach I would take.