Running OpenFire XMPP Server in Docker on Ubuntu Server 🌱

What is OpenFire

Openfire is a real time collaboration (RTC) server licensed under the Open Source Apache License. It uses the only widely adopted open protocol for instant messaging, XMPP Openfire is incredibly easy to setup and administer, but offers rock-solid security and performance. -https://igniterealtime.org/projects/openfire/

Installing Docker

  1. Log into the Linux based device
  2. Run the following commands in the terminal
    # install prerequisites
    sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
    # add docker gpg key
    curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
    # install docker
    sudo apt install docker-ce docker-compose containerd.io -y
    # enable and start docker service
    sudo systemctl enable docker && sudo systemctl start docker
    # add the current user to the docker group
    sudo usermod -aG docker $USER
    # reauthenticate for the new group membership to take effect
    su - $USER

Running OpenFire

  1. Now that Docker is installed, run the following commands to setup the OpenFire Docker container and run it
    # create a working directory
    mkdir /home/$USER/docker/openfire/db -p
    # run the OpenFire docker container
    docker run --name openfire -d -p 9090:9090 -p 5222:5222 -p 5269:5269 -p 5223:5223 -p 7443:7443 -p 7777:7777 -p 7070:7070 -p 5229:5229 -p 5275:5275 -v /home/$USER/docker/openfire/db:/var/lib/openfire/embedded-db --restart=unless-stopped quantumobject/docker-openfire
  2. Open a web browser and navigate to http://DNSorIP:9090
  3. Select a language > Click Continue
  4. Set the XMPP Domain Name and Server Host Name (FQDN) to local > Click Continue
  5. Select Embedded Database > Click Continue
  6. Select Default on the Profile Settings page > Click Continue
  7. Input an admin email address and password > Click Continue
  8. Click the Login to the admin console button
  9. Login with username admin and the password created previously
  10. Click the Users/Groups tab
  11. Click Create New User in the left navigation menu
  12. Create a username and password for the new user
  13. Follow the steps to create as many users as needed, at least 2 are needed for testing

Making the Configuration Persistent

  1. With OpenFire now configured, run the following commands to copy the configuration files to a persistent volume and re-run the docker container
    # create working directory for conf
    mkdir /home/$USER/docker/openfire/conf -p
    # copy the configuration from the running docker container
    sudo docker cp openfire:/usr/share/openfire/conf/ /home/$USER/docker/openfire
    # set owner of working directories
    sudo chown "$USER":"$USER" /home/"$USER"/docker -R
    # stop and remove the running OpenFire container
    docker rm openfire --force
    # re-run the OpenFire docker container with new conf volume
    docker run --name openfire -d -p 9090:9090 -p 5222:5222 -p 5269:5269 -p 5223:5223 -p 7443:7443 -p 7777:7777 -p 7070:7070 -p 5229:5229 -p 5275:5275 -v /home/$USER/docker/openfire/db:/var/lib/openfire/embedded-db -v /home/$USER/docker/openfire/conf:/usr/share/openfire/conf --restart=unless-stopped quantumobject/docker-openfire

Setting Up A XMPP Client

  1. Download Pidgin Portable Download
  2. Run the Pidgin Portable installer
  3. Launch Pidgin Portable
  4. Click Add...
  5. Select XMPP from the protocol dropdown
  6. Input the first username created above along with the XMPP domain setup in OpenFire and the user's password
  7. Click the Advanced tab > Select Use encryption if available from the Connection security dropdown
  8. Enter the OpenFire DNS name or IP in the server field
  9. Click the Add button
  10. Click Accept on the self-signed certificate popup
  11. Copy the extracted Pidgin Portable folder to another device
  12. Launch Pidgin Portable on the second device
  13. Select Modify Account
  14. Update the username and password to be a different account from the previous device
  15. From one of the devices, select Buddies > Add Buddy
  16. Input the opposite devices's username
  17. On the second device accept the message request and the two devices should be able to send and receive instant messages using the OpenFire XMPP server

Documentation: https://github.com/QuantumObject/docker-openfire