This effort is to get Mycodo running in Docker containers with all features working. Many parts of the system work, however there are also many that do not.
This is currently experimental
Please do not submit github issues for Docker-related problems. Also do not expect this feature to remain consistent (i.e. previous builds may not be compatible with future builds). Join Docker Issue (#637) for Mycodo Docker discussion.
This has been tested to work with:
- Raspberry Pi running Raspberry Pi OS
- PC running Ubuntu Linux (20.04, 64-bit)
A Dockerized Mycodo instance cannot run if there is a local install of Mycodo also running because they use the same ports. You can stop any local, non-Docker Mycodo instances prior to building with the following commands. Note that this will only stop these services until reboot.
sudo service mycodo stop
sudo service mycodoflask stop
sudo service nginx stopIf you are building for a Pi Zero, you will need to change FROM influxdb:1.8.10 to FROM mendhak/arm32v6-influxdb in docker/influxdb/Dockerfile prior to building.
If installing on on a Raspberry Pi, Docker requires Rust be installed. You can skip this step and attempt to install Docker in the next command. If you get an error about Rust being missing, then come back and install it, then try installing Docker again.
curl https://sh.rustup.rs -sSf | sh
Install Docker. If you have docker already installed via another method, do not run this install script. Only run this install script if you don't already have Docker or you preiously installed docker with this install script.
curl https://get.docker.com -sSf | shAdd your user to the docker group to be able to execute doker commands.
sudo usermod -aG docker $USER
Log out then back in to make the group changes go into effect before attempting to build.
Edit docker-compose.yaml and change both (2) instances of TZ=America/New_York to your time zone. This setting is located under both mycodo_daemon and mycodo_flask
cd ~/Mycodo
docker compose build
docker compose up -dMycodo can be accessed at https://127.0.0.1
For consistency, I will now go through the steps to installing Mycodo in Docker containers with the use of a virtual machine that can be run from Windows, Mac, or Linux. This ensures a consistent platform to test from and reduces the issues that can occur with the use of different Linux distributions. If you're having issues with the above installation steps, try the method below.
Install Virtualbox from https://www.virtualbox.org/wiki/Downloads
Download the Debian Buster with Raspberry Pi Desktop ISO or ISO of another Debian-based Linux distribution.
- Start VirtualBox and click
Newto create a new virtual machine. - Enter a name, change the Type to
Linux, and version toDebian (64-bit), then click Next. - Select at least 1024 MB RAM to allocate to this virtual machine, then click Next.
- Select
Create a virtual hard disk now, then click Next. - Select
VDI (VirtualBox Disk Image), then click Next. - Select
Dynamically allocated, then click Next. - Raspbian will take up around 8 GB, so allocate at least 12 GB on the next screen, then click Create.
- Select the new virtual machine that was just created, then click
Settings. - Click
Storageon the left menu, then underController: IDE, selectEmpty, then underAttributeson the right, click the disc icon next toOptical Drive, then selectChoose Virtual Optical Disk Fileand select the Raspbian ISO that was downloaded. - Click OK to close the settings menu.
- Start the virtual machine by clicking Start.
- Once the virtual machine starts, you will be presented with a menu titled
Debian GNU/Linux menu (BIOS mode). Selectinstall. - Select your language, then press Enter.
- On the
Partition discsscreen, selectGuided - use entire disk, then press Enter. - On the next screen, select the only disk that's presented, then press Enter.
- On the next screen, select
All files in one partition (recommended for new users), then press Enter. - On the next screen, select
Finish partitioning and write changes to disk, then press Enter. - On the next screen, select
<Yes>to theWrite the changes to disks?question, then press Enter. - On the
Install the GRUB boot loader on a hard diskscreen, select<Yes>to theInstall the GRUB boot loader to the master boot record?question, then press Enter. - On the next screen, select
/dev/sda, then press Enter. - Give the next processes ample time to complete.
- On the
Finish the installationscreen, select<Continue>, then press Enter. - Once the virtual machine reboots, the Raspbian desktop should load and present a graphical setup to finish installing Raspbian. Follow the prompts to complete the install.
- At this point is is recommended to open a terminal and run
sudo apt update && sudo apt upgradeto upgrade your system software to the latest version (if you haven't already done this in the graphical setup).
Open a terminal in Raspbian and run the following commands.
sudo apt-get install -y jq
cd ~
curl -s https://api.github.com/repos/kizniche/Mycodo/releases/latest | \
jq -r '.tarball_url' | wget -i - -O mycodo-latest.tar.gz
mkdir Mycodo
tar xzf mycodo-latest.tar.gz -C Mycodo --strip-components=1
rm -f mycodo-latest.tar.gzThen follow the instructions to Install Prerequisites and Build and Start.
If Grafana was enabled prior to the build, it can be accessed at http://127.0.0.1:3000
The default user is admin and the password admin.
If you change code and want to rebuild to incorporate it into the running conatiners, all you need to do is rebuild and restart the containers.
cd ~/MycodoTo stop the running containers and prevent them from automatically starting when the system start.
cd ~/Mycodo/docker
docker compose downIf the containers have been stopped or brought down, you can bring them back up or start them again. The system has to have been previously built for this to work.
cd ~/Mycodo
docker compose up -dTo bring down all containers and delete all image data (volume data is preserved).
cd ~/Mycodo
docker compose down
docker system prune -aFor reference, this is the guide used to implement Grafana and Telegraf: https://towardsdatascience.com/get-system-metrics-for-5-min-with-docker-telegraf-influxdb-and-grafana-97cfd957f0ac
Grafana and Telegraf are disabled by default. To enable either or both of these features (prior to building), open docker-compose.yml and uncomment the blocks that follow the statement "Uncomment the following blocks and rebuild to enable Grafana and/or Telegraf", save, then rebuild.
Grafana will be accessible at http://127.0.0.1:3000
After logging in and changing the admin password, select "Add data source", then "InfluxDB". Enter the following information:
- Name: InfluxDB-mycodo
- Default: Checked
- URL: http://mycodo_influxdb:8086
- Database: mycodo_db
- User: mycodo
- Password: mmdu77sj3nIoiajjs
Click "Save and Test"
Hover over Dashboards at the top-left, then click Import. Enter 928 as the Grafana Dashboard URL, then click Load. Select InfluxDB-mycodo as the data source for the InfluxDB telegraf field, then click Import. Once the dashboard has loaded, click Save Dashboard at the top of the dashboard.