version: '3'
services:
db:
image: mariadb:10.6
container_name: pb-mariadb
restart: unless-stopped
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "passbolt"
MYSQL_USER: "passbolt"
MYSQL_PASSWORD: "P4ssb0lt"
volumes:
- ./data:/var/lib/mysql
passbolt:
image: passbolt/passbolt:latest-ce
container_name: pb-passbolt
restart: unless-stopped
depends_on:
- db
environment:
APP_FULL_BASE_URL: http://10.10.xxx.xxx:80
DATASOURCES_DEFAULT_HOST: "db"
DATASOURCES_DEFAULT_USERNAME: "passbolt"
DATASOURCES_DEFAULT_PASSWORD: "P4ssb0lt"
DATASOURCES_DEFAULT_DATABASE: "passbolt"
PASSBOLT_REGISTRATION_PUBLIC: "true"
EMAIL_DEFAULT_FROM: "liubei-cto@xishu.com.cn"
EMAIL_TRANSPORT_DEFAULT_HOST: "mail.xishu.com.cn"
EMAIL_TRANSPORT_DEFAULT_PORT: "25"
EMAIL_TRANSPORT_DEFAULT_USERNAME: "liubei-cto@xishu.com.cn"
EMAIL_TRANSPORT_DEFAULT_PASSWORD: "liubei@161"
#EMAIL_TRANSPORT_DEFAULT_TLS: "true"
volumes:
- ./gpg:/etc/passbolt/gpg
- ./jwt:/etc/passbolt/jwt
command: ["/usr/bin/wait-for.sh", "-t", "0", "db:3306", "--", "/docker-entrypoint.sh"]
ports:
- 80:80
- 443:443
mkdir {data,gpg,jwt}
chmod 777 gpg jwt
说明:
- 镜像的工作用户不是宿主机的root用户,我们现在并不知道它是谁
- 它需要在gpg和jwt两个目录里写文件,我们此时先给一个777权限
- 容器启动后,我们将看见这个用户写入文件
- 从文件我们可以知道这个用户是谁
- 再将目录的所有者改成这个用户,并把权限给回755或者750
[root@liubei passbolt]# docker-compose up -d
Creating network "passbolt_default" with the default driver
Creating pb-mariadb ... done
Creating pb-passbolt ... done
[root@liubei passbolt]# docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------------------
pb-mariadb docker-entrypoint.sh mariadbd Up 3306/tcp
pb-passbolt /usr/bin/wait-for.sh -t 0 ... Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
[root@liubei passbolt]# ll gpg/
总用量 12
-rw-r--r-- 1 33 tape 2456 12月 27 15:14 serverkey.asc
-rw-r--r-- 1 33 tape 5091 12月 27 15:14 serverkey_private.as
[root@liubei passbolt]chown 33.33 gpg jwt
[root@liubei passbolt]chmod 755 gpg jwt
docker exec pb-passbolt su -m -c "bin/cake passbolt register_user -u liubei-cto@xishu.com.cn -f bei -l liu -r admin" -s /bin/sh www-data
至此就可以正常使用了,如果需要使用https访问,你可以继续往下看
APP_FULL_BASE_URL
值如下:APP_FULL_BASE_URL: https://10.10.xxx.xxx
volumes:
- ./gpg:/etc/passbolt/gpg
- ./jwt:/etc/passbolt/jwt
# 添加下边两行
- ./xishu.com/xishu.com.pem:/etc/ssl/certs/certificate.crt
- ./xishu.com/xishu.com.key:/etc/ssl/certs/certificate.key
xishu.com.pem和xishu.com.key是我得证书文件和密钥,换成你自己的
docker-compose down
docker-compose up -d