2

I'm configuring a .emacs.d folder for putting inside a Docker container. On Docker, I need to install all the tools that I want on my image while I'm building the image. Even though I can properly put my .emacs.d folder in the right place, I always rely on opening emacs inside the docker image (the first time after building it) and waiting it to install all the emacs packages from my init.el file after creating the image. I'd like to install those packages while I'm building my docker image.

Is there any emacs command I can use to run the init.el file from the command line? Just so my configurations will be ready to use in the docker container when I open it for the first time?

2
  • Can't you map the init.el file into the container, start up emacs in the container, wait for it to install all the packages and then dump that image? Then when you start a container from the dumped image, it will have everything, no?
    – NickD
    Dec 27, 2022 at 19:29
  • @NickD Even though it's possible it wouldn't be the ideal solution for me. I'd like to deal with it directly on my Dockerfile. For example, with Vim I can use vim +PlugInstall +qall and install everything from the command line. I'd like to find something similar for emacs.
    – raylight
    Dec 27, 2022 at 19:40

1 Answer 1

2

In general, you can invoke Emacs with the --batch flag and pass Elisp code to evaluate using either --eval (-e) if you have an expression you'd like to evaluate, such as (package-install 'foo) or you could use --script if you wish to evaluate a file. Note that --batch implies --no-init-file, so Emacs might not behave as it does during regular sessions.

1
  • 2
    Thanks! The line RUN emacs --batch --script /root/.emacs.d/init.el worked perfectly inside the Dockerfile.
    – raylight
    Dec 28, 2022 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.