雑木林

頭の中の整理と忘れないための確認メモ

raspberry pi上でnextcloudを動作させる

前回から日が空きましたが、NextcloudをRaspberry pi で動かすの続き。
Nextcloudのdockerイメージはあるので、前回作ったmariadbと組み合わせるだけです。

環境

docker-compose.ymlはこんな感じ。
適宜、mariadbのパスワードやボリュームのパスは変更してください。

version: '3'
services:
  nc_db:
    build: alpine_mariadb
    restart: always
    volumes:
      - ./mariadb/var/lib/mysql:/var/lib/mysql
    environment:
      - DB_ROOT_PASS=!Passw0rd
      - DB_NAME=nextcloud
      - DB_USER=nextcloud
      - DB_PASS=!Passw0rd
    container_name: nextcloud_db
  nextcloud:
    container_name: nextcloud
    image: nextcloud
    restart: always
    links:
      - nc_db
    ports:
      - "80:80"
    volumes:
      - "./nextcloud/var/www/html:/var/www/html"

起動するとこんな感じ。

$ docker-compose up -d
Creating network "nextcloud_default" with the default driver
Building nc_db
Step 1/6 : FROM alpine:latest
latest: Pulling from library/alpine
99fc70ac0b64: Pull complete
Digest: sha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a
Status: Downloaded newer image for alpine:latest
 ---> 27560c0c9c97
Step 2/6 : ENV DB_DATA_PATH="/var/lib/mysql"     DB_ROOT_PASS="mariadb_root_password"     DB_NAME="sampledb"     DB_USER="mariadb_user"     DB_PASS="mariadb_user_password"
 ---> Running in d3b1b00f75c8
Removing intermediate container d3b1b00f75c8
 ---> 56b92453d53e
Step 3/6 : RUN apk --no-cache update     && apk --no-cache add openrc mariadb mariadb-client tzdata     && cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime     && echo "Asia/Tokyo" > /etc/timezone     && apk del tzdata     && sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf     && echo 'rc_provide="loopback net"' >> /etc/rc.conf     && sed -i 's/^#\(rc_logger="YES"\)$/\1/' /etc/rc.conf     && sed -i '/tty/d' /etc/inittab     && sed -i 's/hostname $opts/# hostname $opts/g' /etc/init.d/hostname     && sed -i 's/mount -t tmpfs/# mount -t tmpfs/g' /lib/rc/sh/init.sh     && sed -i 's/cgroup_add_service /# cgroup_add_service /g' /lib/rc/sh/openrc-run.sh     && rc-status     && touch /run/openrc/softlevel     && sed -i 's/^skip-networking/skip-networking = 0\nskip-bind-address\nskip-name-resolve\nport = 3306\ncharacter-set-server = utf8/g' /etc/my.cnf.d/mariadb-server.cnf
 ---> Running in b243e28a2daf
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/armv7/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/armv7/APKINDEX.tar.gz
v3.10.3-39-g3eab7ec650 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.3-20-g9fd7505b58 [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
OK: 10068 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/armv7/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/armv7/APKINDEX.tar.gz
(1/16) Installing mariadb-common (10.3.18-r0)
(2/16) Installing libaio (0.3.111-r0)
(3/16) Installing xz-libs (5.2.4-r0)
(4/16) Installing ncurses-terminfo-base (6.1_p20190518-r0)
(5/16) Installing ncurses-terminfo (6.1_p20190518-r0)
(6/16) Installing ncurses-libs (6.1_p20190518-r0)
(7/16) Installing linux-pam (1.3.0-r1)
(8/16) Installing pcre (8.43-r0)
(9/16) Installing libgcc (8.3.0-r0)
(10/16) Installing libstdc++ (8.3.0-r0)
(11/16) Installing libxml2 (2.9.9-r2)
(12/16) Installing mariadb (10.3.18-r0)
Executing mariadb-10.3.18-r0.pre-install
(13/16) Installing mariadb-client (10.3.18-r0)
(14/16) Installing openrc (0.41.2-r1)
Executing openrc-0.41.2-r1.post-install
(15/16) Installing mariadb-openrc (10.3.18-r0)
(16/16) Installing tzdata (2019c-r0)
Executing busybox-1.30.1-r2.trigger
OK: 150 MiB in 30 packages
WARNING: Ignoring APKINDEX.00740ba1.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.d8b2a6f4.tar.gz: No such file or directory
(1/1) Purging tzdata (2019c-r0)
Executing busybox-1.30.1-r2.trigger
OK: 147 MiB in 29 packages
 * Caching service dependencies ... [ ok ]
Runlevel: sysinit
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
Dynamic Runlevel: manual
Removing intermediate container b243e28a2daf
 ---> 60f8d44f50cf
Step 4/6 : COPY entrypoint.sh /root/entrypoint.sh
 ---> c022841a038a
Step 5/6 : ENTRYPOINT /bin/sh /root/entrypoint.sh
 ---> Running in 74f24f5c6825
Removing intermediate container 74f24f5c6825
 ---> 0c2ced1e50bb
Step 6/6 : EXPOSE 3306
 ---> Running in aba5dec0d268
Removing intermediate container aba5dec0d268
 ---> 6addd7b7cb23
Successfully built 6addd7b7cb23
Successfully tagged nextcloud_nc_db:latest
WARNING: Image for service nc_db was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Pulling nextcloud (nextcloud:)...
latest: Pulling from library/nextcloud
ffb3a1edd2f5: Pull complete
42c8dffb43ff: Pull complete
4d458100cdee: Pull complete
ecc3400b24e8: Pull complete
eacbf6c67316: Pull complete
dc5af305f5a9: Pull complete
a309a29c23f9: Pull complete
140ff9512340: Pull complete
87fec2d1ba1c: Pull complete
d2c689828e3b: Pull complete
82e67bdbfc9b: Pull complete
9ff2efc8b096: Pull complete
552b0063d416: Pull complete
b29db435b461: Pull complete
26861b5bb115: Pull complete
0fa7931079e0: Pull complete
04b977ffe351: Pull complete
6c1c73d1419b: Pull complete
684209d30b89: Pull complete
760264ca21c9: Pull complete
9fe049a2d48d: Pull complete
Digest: sha256:d677b0b017831c3f772a0b9769cec3f05b1fd316271f933d65a6fe65b52cb0f8
Status: Downloaded newer image for nextcloud:latest
Creating nextcloud_db ... done
Creating nextcloud    ... done


$ docker-compose ps
    Name                  Command               State         Ports
--------------------------------------------------------------------------
nextcloud      /entrypoint.sh apache2-for ...   Up      0.0.0.0:80->80/tcp
nextcloud_db   /bin/sh -c /bin/sh /root/e ...   Up      3306/tcp

Web画面にアクセスすると初期設定画面が表示されるので、DB情報を入力します。

f:id:zokibayashi:20191117162451p:plain

問題なければNextcloudが利用できます。 f:id:zokibayashi:20191117164840p:plain