1

I'm currently facing the problem of Emacs not being able to connect to MELPA. When researching this problem, I found out that this problem is discussed in many topics. However, every suggested solution I tried didn't work for me, beside that, the way I've set up my Emacs instance makes me think the root of the problem might be somewhere else (not emacs related itself).

So let me explain my setup: I have a Windows 10 host, and I'm trying to get GUI Emacs for Linux running on that host. I've tried various methods (VMs, Emacs for Windows, ...). Currently I'm trying to run Emacs inside a Docker container with X11 forwarding with XMing on my host.

Docker version on host: Docker version 19.03.2, build 6a30dfc I'm using this docker container as a base. However I modified the Dockerfile a bit to fit my needs (I should mention that I've never worked with docker before):

FROM alpine:edge
MAINTAINER Daniel Guerra <daniel.guerra69@gmail.com>

ARG authorizedKeys=authorized_keys

RUN apk add --update openssh util-linux dbus ttf-freefont xauth xf86-input-keyboard emacs-x11 bash git sudo\
&& rm  -rf /tmp/* /var/cache/apk/*

RUN addgroup alpine \
&& adduser  -G alpine -s /bin/bash -D alpine \
&& echo "alpine:alpine" | /usr/sbin/chpasswd \
&& echo "alpine    ALL=(ALL) ALL" >> /etc/sudoers

RUN cp -r /etc/ssh /ssh_orig
RUN rm -rf /etc/ssh/*

ADD etc /etc
ADD docker-entrypoint.sh /usr/local/bin

VOLUME ["/etc/ssh"]

RUN mkdir -p /home/alpine/.ssh
ADD $authorizedKeys /home/alpine/.ssh/authorized_keys

RUN mkdir -p /home/alpine/.config
RUN git clone https://github.com/minikN/dotemacs.git /home/alpine/.config/emacs/

RUN mkdir -p /home/alpine/.emacs.d
RUN ln -s /home/alpine/.config/emacs/init.el /home/alpine/.emacs.d/init.el
RUN ln -s /home/alpine/.config/emacs/config.el /home/alpine/.emacs.d/config.el
RUN ln -s /home/alpine/.config/emacs/config.org /home/alpine/.emacs.d/config.org

RUN chown -R alpine:alpine /home/alpine/.emacs.d

ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["/usr/sbin/sshd","-D"]

I basically copy my hosts authorized_keys to the container. I do this because I'm using Putty and it's ssh-agent to connect to the machine via SSH.

After that I just copy my emacs config from my GitHub to the container. You can find the emacs config here.

If I now start the container connect to it via SSH and start emacs, it opens in XMing. However it just hangs (in fact the whole container hangs up), I just see a white screen. Upon restarting the container and running emacs --daemon I can see that it hangs at

alpine-sshdx:~$ emacs --daemon
Contacting host: melpa.org:443

BTW I've checked several mirrors. melpa.org:443 is just the latest try. Also tried both HTTP/HTTPS.

However doing ping 8.8.8.8 works just fine.

I have absolutely no idea what the cause of this is. But I believe it's something in the container.

Would appreciate any help.

  • What's your real end goal? My first instinct would be to install a native Emacs on your host; my second would be to make the container's `CMD` be [`emacs --daemon`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html) with additional configuration to make it [listen on a TCP port](https://www.gnu.org/software/emacs/manual/html_node/emacs/TCP-Emacs-server.html#TCP-Emacs-server). Both sshd and GUI applications in Docker are pretty complex topics. – David Maze Oct 16 '19 at 10:47
  • My end goal is to use the GUI version of Emacs. However I want to use it within a linux environment. On the other hand I can't change my host OS due to my company's policy. I've tried using a simple linux vm using VirtualBox. But on the hand, for just using emacs it seemly kinda heavy to me. Secondly I need to connect to the VM (or docker container) using ssh. Simply using the VM wouldn't do it because I wouldn't be authenticated properly. – Artemios Antonio Balbach Oct 16 '19 at 11:10
  • I also don't need to use the emacs daemon. I just used the command to see in the console where it hangs up. Also, the GUI part isn't the problem. Emacs starts as I said, just hangs upon connecting to MELPA. I've also tested Firefox and some other applications. They all work just fine. – Artemios Antonio Balbach Oct 16 '19 at 11:11
  • Try using `emacs -q` or `emacs -Q` to eliminate your config from the equation. Then incrementally run commands from your config or just run commands (e.g. run `ping` or `curl` from emacs to see if it still works). FWIW, docker on windows necessarily uses a VM, but it's probably lighter weight than a full VBox VM. – jpkotta Oct 16 '19 at 22:57
  • Hallo, thanks for the input. I knew that my config is at least part of the problem. Because emacs starts up just fine without the config or with `emacs -q`. However, trying to run certain commands in emacs causes it to hang up too. Like `M-x term` or `ping`. I don't really know what to make of this. – Artemios Antonio Balbach Oct 17 '19 at 08:51
  • Just to add something. "All" I wanna do is run linux gui emacs on my windows host. If anyone has a different idea I'm happy for input. – Artemios Antonio Balbach Oct 17 '19 at 08:53
  • 1
    `msys2` is a reasonable option for running an emacs gui in windows. You also get all the standard unix tools like `find`, `grep`, `bash`, etc. It can be quite slow though, which as I understand is due to slow `fork()` and slow file access. – jpkotta Oct 17 '19 at 17:01
  • @jpkotta Thanks for the input. I tried `msys2`. I installed the mingw version of emacs and yeah I can start it just fine using `C:\msys64\mingw64\bin\runemacs.exe`. However, how would I get access to the unix tools like `bash`, `cd` ect? If I do `M-x shell` it starts a windows shell. – Artemios Antonio Balbach Oct 22 '19 at 09:19
  • Nevermind, I got it. – Artemios Antonio Balbach Oct 22 '19 at 15:46
  • Did you find a solution to this? – Nisba Aug 07 '22 at 19:04

0 Answers0