拉取最新版本的 Firefly III 鏡像:
$ sudo docker pull fireflyiii/core:latest
在本地預(yù)先創(chuàng)建好 upload 和 export 目錄, 用于映射 Firefly III 容器內(nèi)的 /var/www/html/storage/upload 和 /var/www/html/storage/export 目錄。
使用以下命令來運(yùn)行 Firefly III 容器:
$ sudo docker run -d --name fireflyiii -e APP_KEY=xxx -e DB_HOST=127.0.0.1 -e DB_CONNECTION=pgsql -e DB_PORT=5432 -e DB_DATABASE=firefly -e DB_USERNAME=firefly -e DB_PASSWORD=xxx -p 10087:8080 -v /home/ubuntu/docker/fireflyiii/upload:/var/www/html/storage/upload -v /home/ubuntu/docker/fireflyiii/export:/var/www/html/storage/export fireflyiii/core:latest
-
-d(保持STDIN打開狀態(tài)) -
--name(給容器起一個(gè)名字方便管理) -
-e APP_KEY=xxx(環(huán)境變量, 使用head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9' | head -c 32 && echo生成) -
-e DB_HOST=127.0.0.1(環(huán)境變量, 數(shù)據(jù)庫(kù)地址) -
-e DB_CONNECTION=pgsql(環(huán)境變量, 數(shù)據(jù)庫(kù)類型) -
-e DB_PORT=5432(環(huán)境變量, 數(shù)據(jù)庫(kù)端口) -
-e DB_DATABASE=firefly(環(huán)境變量, 數(shù)據(jù)庫(kù)庫(kù)名) -
-e DB_USERNAME=firefly(環(huán)境變量, 數(shù)據(jù)庫(kù)用戶) -
-e DB_PASSWORD=xxx(環(huán)境變量, 數(shù)據(jù)庫(kù)密碼) -
-p 10087:8080(將容器的8080端口映射到主機(jī)的10087端口) -
-v /home/ubuntu/docker/fireflyiii/upload:/var/www/html/storage/upload(文件掛載目錄, 存放上傳文件) -
-v /home/ubuntu/docker/fireflyiii/export:/var/www/html/storage/export(文件掛載目錄, 存放導(dǎo)出文件)
通過 docker ps 命令查看容器的運(yùn)行信息:
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13c2a7e55067 fireflyiii/core:latest "/usr/local/bin/entr…" 14 seconds ago Up 13 seconds (health: starting) 0.0.0.0:10087->8080/tcp, :::10087->8080/tcp fireflyiii
現(xiàn)在可以訪問搭建好的 Firefly III 網(wǎng)站了。
如果需要配置反向代理實(shí)現(xiàn) HTTPS 訪問, 還需要在啟動(dòng)時(shí)添加下面兩個(gè)環(huán)境變量:
-e APP_URL=https://firefly.example.com-e TRUSTED_PROXIES=**