Docker installation option

The docker installation utilizes the Dockerfile located in the root directory of pattoo. The code that handles the docker installation can be found in the setup/_pattoo/docker.py folder.

However, if you desire to run the docker installation outside of the pattoo installation script it can be achieved by doing the following:

  1. The docker container is built using the following command:

    $ docker build -t pattoo .
    
  2. Run the container in detached mode with the --privileged tag and the --network tag set to host.

    $ docker run --privileged -d --network=host --name=pattoo pattoo
    

Note) The container is run in detached mode, with the network set to host, to allow the pattoo container to communicate with the host machine’s MySQL or MariaDB database for pattoo. Additionally, the container is run in privileged mode to allow the system daemons to be run in the docker container.

  1. Run the pattoo installation in the container

    $ docker exec -i pattoo setup/install.py install all
    

Dockerfile Breakdown

Pulling the base image

This sets the base image for the pattoo container to the latest version of ubuntu.

FROM ubuntu:latest

Installing python to container

Since the Ubuntu image doesn’t have python or installed by default, it has to be installed via apt

RUN apt-get update \
 && apt-get install -y python3-pip python3-dev \
 && cd /usr/local/bin \
 && ln -s /usr/bin/python3 python \
 && pip3 install --upgrade pip

Disabling the interactive mode for the Debian frontend

This sets the DEBIAN_FRONTEND variable to its non-interactive mode to prevent the build from failing due to user input being required.

ARG DEBIAN_FRONTEND=noninteractive

Set working directory to pattoo

WORKDIR "/pattoo"

Install systemd package

Since the base image for ubuntu does not have systemd installed by default, it has to be installed via apt

RUN apt-get install -y systemd

Copy repository contents

This copies all of the contents in the directory with the Dockerfile, excluding files and directories listed in the .dockerignore file.

COPY . /pattoo

Expose the respective ports

To allow the daemons to communicate outside of the docker container, the respective ports will have to be exposed in the Dockerfile. Fortunately, if the installation is run with the installation script, all ports listed in the pattoo_server.yaml file will be automatically inserted in the Dockerfile.

EXPOSE 20203
EXPOSE 20202
EXPOSE 20201
EXPOSE 3306

Start systemd

By default the systemd service will not be activated in a docker container. So the /usr/bin/systemd file has to be executed to allow daemons to run in the docker container.

CMD ["/usr/bin/systemd"]