How to programmatically push a docker image to a docker registry?

I’ve looked online for an answer, but all I could find were articles about dockerizing a node app and pushing it to docker hub or another registry. My question is different.

I programmatically generate some basic files in a folder. One of the root files is a Dockerfile, which I use to build a docker image with child-process. After I build this image, I’d like to push it to my docker registry (not docker hub).

What options am I left with here? Using child-process again after building the image?