Put Redmine docker container in Raspberry Pi 4 Model B 2GB

Background (Ikisatsu)

The introduction is long, but it is a story that I decided to build redmine after purchasing w HDD. If the wind blows, the tub shop will be profitable.

Prerequisites

  1. Raspberry Pi 4 Model B (2GB) * Link destination is 8GB
  2. 32GB microSD card
  3. Type-C AC Adapter
  4. Raspbian 10.7 installed
  5. You can connect with ssh (the following procedure assumes that you are connected as the pi user)

procedure

Step 1: Install docker-compose

It was written that pip3 can be executed without doing anything if it feels like google. But in my case, there is no such command! Something is wrong! Etc. orz to error So python3 installation, pip3 upgrade and wheel installation I think you should do it without thinking about anything.

sudo apt-get update #Magical part 1
sudo apt-get -y upgrade #Magic part 2
curl -sSL https://get.docker.com | sh #install docker
sudo apt-get -y install python3-dev #I want to use pip3
sudo apt-get -y install python3-pip #I want to use pip3
sudo pip3 install --upgrade setuptools #Because pip3 may get an error
sudo pip3 install wheel #Because pip3 may get an error
sudo pip3 install docker-compose # docker-install compose

Step 2: Ready to start (maybe you don't have to)

When I was googled, there was an article that made the following settings, so I did it for the time being. However, this does not seem to be a problem if you do not do it. You can run docker with sudo.

sudo vi .bashrc
#The added line is as follows (in my case)~/.This setting doesn't seem to be necessary as local didn't exist)
# export PATH="$PATH:~/.local/bin
source .bashrc #Reflect the above settings
echo $PATH #Check if it was reflected
sudo usermod -a -G docker pi #Set docker command to be executed by user pi
sudo reboot #Reboot just in case

Step 3: Run docker-compose

Please change the following / path/to/docker-compose according to your environment. When the execution is completed so far, from the PC browser to http: // {Raspberry Pi IP address}: 3000 You should see the redmine screen by accessing it.

mkdir /path/to/docker-compose #Create a working directory
sudo chown root:users /path/to/docker-compose/ #Ownership settings (user pi is the users group)
sudo chmod 775 /path/to/docker-compose/ #Access right setting (user pi is users group)
cd /path/to/docker-compose #Move to working directory
sudo touch docker-compose.yml #Create yaml file
sudo vi docker-compose.yml #Please refer to the following for the edited contents
docker-compose -f docker-compose.yml up -d #Run

The created yaml file has the following contents. Port number, DB name, password, etc. Please set it arbitrarily.

docker-compose.yml

docker-compose.yml


version: '3.8'
services:
  redmine:
    image: arm32v7/redmine
    container_name: redmine
    ports:
      - 3000:3000
    volumes:
      - ./files:/usr/src/redmine/files
      - ./log:/usr/src/redmine/log
      - ./plugins:/usr/src/redmine/plugins
      - ./public/themes:/usr/src/redmine/public/themes
    environment:
      REDMINE_DB_POSTGRES: redmine-db
      REDMINE_DB_DATABASE: redmine
      REDMINE_DB_USERNAME: redmine
      REDMINE_DB_PASSWORD: redmine
      REDMINE_DB_ENCODING: utf8
    depends_on:
      - redmine-db
    restart: always
    
  redmine-db:
    image: postgres
    restart: always
    environment:
      POSTGRES_DB: redmine-db
      POSTGRES_USER: redmine
      POSTGRES_PASSWORD: redmine
    volumes:
      - ./dbdata/:/var/lib/postgresql/data

Step 4: No DB?

docker ps -a

Execution result


CONTAINER ID   IMAGE             COMMAND                  CREATED         STATUS                          PORTS      NAMES
b7090b0ee0a7   arm32v7/redmine   "/docker-entrypoint.…"   8 minutes ago   Restarting (1) 50 seconds ago              redmine
6e7dca7cd79b   postgres          "docker-entrypoint.s…"   8 minutes ago   Up 8 minutes                    5432/tcp   redmine-db

Check STATUS. If it is normal, it will be displayed like Up 8 minutes If there is a problem, it may restart repeatedly. Restarting (1) 50 seconds ago If the redmine container starts repeatedly, the DB may be the problem. In my case, DB migration with redmine didn't work. (When I think about it now, I feel that the DB host name was just wrong in the yaml settings ... I can't migrate because the host is unknown) ActiveRecord::NoDatabaseError: FATAL: database "redmine" does not exist Create the database manually.

docker logs redmine #Check the log
docker container exec -it redmine-db /bin/bash #Enter the DB container
createdb redmine --encoding=utf8 -O redmine -U redmine #CREATE DATABASE
exit #Exit the DB container
docker rm redmine #Delete the redmine container
docker-compose -f docker-compose.yml up -d #Remake again

Supplement (more)

Check if docker and docker-compose have been installed

docker -v
docker pull hello-world
docker run hello-world
docker ps -a
docker rm hungry_roentgen
docker images
docker rmi hello-world
docker-compose version

Frequently used docker commands

docker ps -a #List of containers
docker stop container_name #Stop container
docker start container_name #Start container
docker logs container_name #View container logs
docker rm container_name #Delete container
docker rename before after #Rename container
docker images #List images
docker rmi image_name #Delete image

podman on Ubuntu

First, the article I found put Ubuntu in Raspberry Pi The content was to build redmine with podman. I didn't read that it's Ubuntu, not raspbian "I can't do it, why?" ^^ ;;

In conclusion, this method didn't work for me.

That said, I'll give you what I've done.

. /etc/os-release
#The following xUbuntu_Is Raspbian_It's a mistake, but Raspbian_If it is 10, the public key will be an error. ..
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt-get update

First of all, this error (xUbuntu_ is a mistake of Raspbian_)

error contents


Err:15 https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_10  Release
  404  Not Found [IP: 2001:67c:2178:8::13 443]

So delete this list file

rm /etc/apt/sources.list.d/devel\:kubic\:libcontainers\:stable.list 

So, if you change xUbuntu_ to Raspbian_ and run it, you will get the following result.

error contents


The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4D64390375060AA4

I got an error when I tried to get this one.

gpg --recv-key 4D64390375060AA4

error contents


gpg: keyserver receive failed: No data

I can't help it, so I deleted the list again, and if I didn't do it and proceeded ...

sudo apt-get -y upgrade
sudo apt-get -y install podman

error contents


E: Unable to locate package podman

Yes, I gave up.

MySQL or MariaDB

Originally, MySQL is preferable to PostgreSQL (a matter of taste) I don't understand the image well even if I look at docker hub ... I just need to move it for the time being. Great people don't know that.

Consideration of SD card

I didn't do anything when I built the openmediavault environment There was a setting that seemed better to do, so I implemented it this time as well. Please check the meaning of the settings yourself. (By the way, I made a directory for redmine on an external HDD)

sudo swapoff --all
sudo systemctl stop dphys-swapfile
sudo systemctl disable dphys-swapfile
systemctl status dphys-swapfile

Fixed IP address

This is also the content that I did together this time The IP address obtained by DHCP is fixed. It is the setting of the client (Raspberry Pi), not the router side. Since it is a wired connection, the name of if is eth0. I think that the wireless LAN will be something like wan0. (It is a mystery whether the setting is really correct)

sudo vi /etc/dhcpcd.conf

/etc/dhcpcd.conf


interface eth0
static ip_address=192.168.111.123/24
static routers=192.168.111.1
static domain_name_servers=192.168.111.1 8.8.8.8 8.8.4.4

Fire wall?

At first, I didn't notice that the redmine container was restarting repeatedly I can't access http: // {raspberrypi}: 3000 I doubted the network settings. The following contents were set at that time.

sudo apt-get install ufw
sudo ufw allow 22 #For ssh
sudo ufw allow 80 #For now for the management screen of openmediavault
sudo ufw allow 139 # smb://
sudo ufw allow 445 # smb://
sudo ufw allow 3000 #For redmine added this time
sudo ufw default deny #Default setting = reject
sudo ufw enable #enable ufw

Is ufw the major now? I have set it for the time being, so I have left it as it is. For the time being, I also installed nmap because I want to check the status of the port.

sudo apt-get install nmap
nmap localhost

Execution result


Starting Nmap 7.70 ( https://nmap.org ) at 2020-12-XX XX:23 JST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00070s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 995 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3000/tcp open  ppp

Nmap done: 1 IP address (1 host up) scanned in 0.27 seconds

Summary

Recommended Posts

Put Redmine docker container in Raspberry Pi 4 Model B 2GB
Install CentOS 7 on Raspberry pi 4 Model B
Launched Redmine with Docker on Raspberry Pi 3
Install Ubuntu Core 18 on Raspberry Pi 2 Model B
I couldn't install docker with raspberry pi2 b +.
Send emails using Docker container on Raspberry Pi 3
Introduced GROWI to Raspberry Pi 4 Model B (Ubuntu)
Put Ubuntu 20.04.1 on Raspberry Pi 4
Raspberry Pi Kubernetes and Docker downgraded story
Kind @ Mac in Docker and vctl container
I installed Docker on my Raspberry Pi 3
MySQL container does not start in Docker
Directly operate mariadb running in Docker container
[Docker] Start container, start bash in container, delete image
Japanese setting of mysql in Docker container