Installing ODK Central on Ubuntu VM into Azure

We are trying to install ODK Central on Ubuntu VM into Azure. Bellow is some prerequisite steps we have taken on installing the docker and firewall:

sudo apt update
sudo apt install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
sudo apt update
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo apt install ufw
sudo ufw allow ssh
sudo ufw allow 2375
sudo ufw allow 2376
sudo ufw enable

Afterwards, we continued with the steps mentioned in ODK Central Documentation from

git clone https://github.com/getodk/central 

up to

sudo cp files/docker-compose@.service /etc/systemd/system

but when we run

sudo systemctl start docker-compose@central

it failed to start. Here is what we got:

user@ourserver:~/central$ systemctl status docker-compose@central
 docker-compose@central.service - central via docker-compose
   Loaded: loaded (/etc/systemd/system/docker-compose@.service; disabled; vendor
   Active: failed (Result: exit-code) since Fri 2020-06-19 12:48:22 UTC; 12s ago
  Process: 3239 ExecStart=/usr/local/bin/docker-compose up (code=exited, status=
 Main PID: 3239 (code=exited, status=200/CHDIR)

Note that we didn't use DigitalOcean's Ubuntu image with docker, but we installed docker by ourselves following the above steps.
As we are planning to use Central for our data collection activities at the earliest possible, hence, we appreciate if you could help us with solving this problem and make it work.

Thanks,
Kumail

As far as I know ODK Central needs to be installed under the the root user.

Very straightforward steps are described if you use DigitalOcean using ready image with preinstalled Ubuntu+Docker from Marketplace.

If you want to install into your own server or any other Virtual Machine, there are two important points you should pay attention.

  1. After installing Docker allow ports 2375 and 2376
  2. Install ODK Central Server using root user

Follow these steps to install ODK Central into your own virtual machine where only Ubuntu is installed:

Step 1. Install Docker Engine using the repository on Ubuntu

Set up the repository. Update the apt package index

sudo apt update

Install packages to allow apt to use a repository over HTTPS:

sudo apt install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Use the following command to set up the stable repository

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Update the apt package index again

sudo apt update

Install the latest version of Docker Engine and container:

sudo apt install docker-ce

Verify that Docker Engine is installed correctly by running the hello-world image.

sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

Step 2. Configuring Docker

Run this command to download the current stable release of Docker Compose:

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply executable permissions to the binary:

sudo chmod +x /usr/local/bin/docker-compose

Step 3. Configuring firewall for Docker
Enable the UFW firewall to allow only SSH (port 22, rate limited) and 2375/2376 for unencrypted/encrypted communication with the Docker daemon, respectively.
Install UFW

sudo apt install ufw

The following sets up a firewall (this is the first important point):

sudo ufw allow ssh
sudo ufw allow 2375
sudo ufw allow 2376
sudo ufw enable
sudo ufw status

Type y when asked to proceed with operation.

Step 4. Obtain the ODK Central software and installing it on the server

Make sure that you are using root account. If needed change into root account (this is the second important point):

sudo -i

Now you can continue from git clone https://github.com/getodk/central
command in official documentation on how to install ODK Collect.

Hope this helps other enthusiast who wants to test ODK Central Server in their own VM. But I would suggest to use DigitalOcean for production.

Kind regards,
Odil

3 Likes

Thanks Odil for the clear and step-by-step manual. Your help spirit is highly appreciated!

1 Like