Git/gitlab/dockerinstallgitlab
来自康健生活
容器
| 容器 | |
|---|---|
| gitlab | |
| postgresql | |
| redis |
gitlab
| 文件/文件夹 | 装载路径 |
|---|---|
| docker/gitlab-ce/data | /var/opt/gitlab |
| docker/gitlab-ce/config | /etc/gitlab |
| docker/gitlab-ce/log | /var/log/gitlab |
| 标题文字 | 标题文字 |
|---|---|
| GITLAB_SECRETS_OTP_KEY_BASE | long-and-random-alpha-numeric-string |
| GITLAB_SECRETS_SECRET_KEY_BASE | long-and-random-alpha-numeric-string |
| GITLAB_SECRETS_DB_KEY_BASE | long-and-random-alpha-numeric-string |
| DB_NAME | gitlab_db |
| DB_PASS | gitlab_password |
| DB_USER | gitlab_user |
postgresql
pull镜像然后创建持久化目录
docker pull postgres
mkdir -p /opt/postgresql/data
配置
启动postgresql容器
docker run --name postgresql \
-e 'POSTGRES_DB=postgresql_db' \
-e 'POSTGRES_USER=postgresql_user' \
-e 'POSTGRES_PASSWORD=passpostgresql_passwordword' \
-v /opt/postgresql/data:/var/lib/postgresql \
-d postgres
复制一个配置文件的副本到本地目录
docker run -i --rm postgres cat /usr/share/postgresql/postgresql.conf.sample > synology_postgres.conf
指定配置文件的位置,这里会遇到container name 冲突。
docker run -d --name postgres1 -v "/volume1/docker/postgresql/config/synology_postgres.conf":/etc/postgresql/postgresql.conf postgres -c 'config_file=/etc/postgresql/postgresql.conf'
这个命令就是把本地的my-postgres.conf挂载到容器里。
群晖 postgresql
软件安装 postgres 在高级设置的环境里配置
| POSTGRES_PASSWORD | postgresql_password |
| POSTGRES_USER | postgresql_user |
| POSTGRES_DB | postgresql_db |
| POSTGRES_INITDB_ARGS | |
| POSTGRES_INITDB_WALDIR | |
| PGDATA | /var/lib/postgresql/data |
启动postgresql容器
| 文件/文件夹 | 装载路径 |
|---|---|
| /volume1/docker/postgresql/data | /var/lib/postgresql/data |
| /volume1/docker/postgresql/config | /etc/postgresql |
| /volume1/docker/postgresql/log | /var/log/postgresql |
error
1. 运行过程出错,命令
docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bc9d13397466 postgres:latest "docker-entrypoint.s…" About a minute ago Exited (1) About a minute ago postgres1
docker logs bc9d13397466
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
waiting for server to start....postgres: could not access the server configuration file "/etc/postgresql/postgresql.conf": No such file or directory
stopped waiting
pg_ctl: could not start server
Examine the log output.
2. 进入容器时,命令行使用数据库出现err
psql: error: could not connect to server: FATAL: role "root" does not exist
切换到postgres用户,因为这个用户有createdb权限。
sudo -u postgres psql
或者
psql -U postgres
进入容器后,创建gitlab用户和数据库
CREATE USER gitlab_user WITH PASSWORD 'gitlab_password';
创建库
CREATE DATABASE gitlab_db OWNER gitlab_user;
数据库权限赋予 gitlab_user 用户
GRANT ALL PRIVILEGES ON DATABASE gitlab_db to gitlab_user;
导出数据库
docker exec -it pg pg_dump -h localhost -U postgres 数据库名 >/data/dum.sql
redis
| 映射路径 | |
|---|---|
| /volume1/docker/redis/config | /usr/local/etc/redis |
| /volume1/docker/redis/data | /data |
| /volume1/docker/redis/log | /var/log/redis |
在图形安装界面的底部命令行添加
redis-server /usr/local/etc/redis/redis.conf
No categories