ejabberd Development with Docker

We have released a Docker image to help you get started with ejabberd development easily.

ejabberd_docker

Docker image for ejabberd developers is available from Docker Hub: ejabberd/mix

Thanks to this image, you can build ejabberd with dependencies provided in our Docker image, without the need to install any specific tools (beside Docker) directly on your own machine.

Please note that this image can likely be reused as is to build other Erlang or Elixir software.

Pulling ejabberd development Docker image

You can pull ejabberd image for developer with this Docker command:

docker pull ejabberd/mix

Once done, you are ready to build ejabberd from source and add your custom plugin modules.

Building ejabberd from source

You can build ejabberd from source with all dependencies, with the following commands:

git clone https://github.com/processone/ejabberd.git
docker run --rm -v $(pwd):$(pwd) -w $(pwd) ejabberd/mix do deps.get, deps.compile, compile

Alternatively if you do not have Git installed, you can do retrieve compressed source code archive and then build ejabberd:

wget https://github.com/processone/ejabberd/archive/master.zip
unzip ejabberd-master
cd ejabberd-master
docker run --rm -v $(pwd):$(pwd) -w $(pwd) ejabberd/mix do deps.get, deps.compile, compile

Run ejabberd with mix command-line tool attached

During development, you will need to run ejabberd with debug console attached.

First, you can customize the configuration used by ejabberd in development mode by editing the file config/ejabberd.yml. As a default, it will run ejabberd with console attached on domain “localhost”:

docker run --rm -it -p 5222:5222 -p 5280:5280 -v $(pwd):$(pwd) -w $(pwd) --entrypoint="/usr/bin/iex" ejabberd/mix -S mix

You can then directly create a user from Elixir shell:


Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false] Interactive Elixir (1.3.4) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> :ejabberd_auth.try_register("test", "localhost", "passw0rd") {:atomic, :ok}

Finally, you can connect with user “test@localhost” (password: passw0rd) on server on localhost port 5222 and use those parameters to connect with an XMPP client.

Get into the container

If you want to run Erlang command line, you can do so by opening a shell inside the container and then running the command as desired:

docker run -it -v $(pwd):$(pwd) -w $(pwd) --entrypoint="/bin/sh" ejabberd/mix

Troubleshooting

Clock resync

If you have warning about file timestamp being out of sync (Like ‘Clock skew detected’), you may want to force resync your clock before running the build. Docker on MacOS does not force clock resync of Docker after the laptop went to sleep.

You can force clock resync as follow:

docker run -it  --rm --privileged --entrypoint="/sbin/hwclock" ejabberd/mix -s

You can check if the clock of your laptop is in sync with the one inside Docker with the following command:

docker run --rm --entrypoint="/bin/sh" ejabberd/mix -c date -u && date -u

Send us feedback

This image is under development and improvement, so please do not hesitate to send us your feedback, so that we can improve ejabberd development experience.

The goal is to provide a simple easy way to develop ejabberd plugins from any OS, whether you use Linux, MacOS or Windows.

Enjoy !


Let us know what you think 💬


7 thoughts on “ejabberd Development with Docker

  1. Hi Mickael, thanks for this brief tutorial. My question is, do we really need to build ejabberd from source? Because we use Docker, IMHO, what we want to do is just set our server up and running. Need your feedback please. Thank you in advance.

  2. hi Mickael, thanks for this tutorial. I have another question apart from this. Can we add a custom config file while deploying the docker image in kubernetes cluster ?
    Thanks in advance.

    • Running ejabberd on Kubernetes is a big topic. Depending on what you want to achieve you should use a specific approach or setup. Please contact us with specifics and lets see how we can help.

  3. Hi, I’m trying to add an external auth script python. But the supervisor keeps failing start.
    P.S: I’m nee to docker

  4. Hi Micheal, I am able to access ejabberd using simple-XMPP but I like to configure the ejabberd on docker to enable me to use the API, how do I go about that?

Leave a Comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.