{"id":433,"date":"2026-01-26T08:46:22","date_gmt":"2026-01-26T08:46:22","guid":{"rendered":"https:\/\/blog.gpst.net.cn:4008\/?p=433"},"modified":"2026-01-28T06:24:13","modified_gmt":"2026-01-28T06:24:13","slug":"docker%e8%bf%90%e7%bb%b4-%e5%ae%89%e8%a3%85gitlab","status":"publish","type":"post","link":"https:\/\/opshub.com.cn\/?p=433","title":{"rendered":"docker\u8fd0\u7ef4\u2014\u2014\u5b89\u88c5gitlab"},"content":{"rendered":"\n<p>\u4e00\u3001\u62c9\u53d6\u955c\u50cf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker pull gitlab\/gitlab-ce:16.3.3-ce.0<\/code><\/pre>\n\n\n\n<p>\u4e8c\u3001\u542f\u52a8\u5bb9\u5668<\/p>\n\n\n\n<p>etc\u6620\u5c04\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6\uff0clog\u5b58\u50a8\u65e5\u5fd7\uff0cdata\u5b58\u653e\u6570\u636e\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run --name=gitlab \\\n        --hostname=gitlab \\\n        --volume=\/mydata\/gitlab\/etc:\/etc\/gitlab \\\n        --volume=\/mydata\/gitlab\/log:\/var\/log\/gitlab \\\n        --volume=\/mydata\/gitlab\/opt:\/var\/opt\/gitlab \\\n        --privileged \\\n        -p 9922:22 \\\n        --expose=443 \\\n        -p 9980:80 \\\n        --restart=always \\\n        --runtime=runc \\\n        --detach=true \\\n        -t \\\n        gitlab\/gitlab-ce:16.3.3-ce.0 \\\n        \/assets\/wrapper<\/code><\/pre>\n\n\n\n<p>\u4e09\u3001gitlab\u76f8\u5173\u914d\u7f6e<\/p>\n\n\n\n<p>1\u3001\u914d\u7f6e\u5bb9\u5668\u4e2d\u7684\/etc\/gitlab\/gitlab.rb\u7684\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<p>\u6211\u4eec\u6253\u5f00\u6620\u5c04\u6587\u4ef6\/mydata\/gitlab\/etc\/gitlab.rb\u5c31\u53ef\u4ee5\u4fee\u6539\uff0c\u4fee\u6539\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>external_url 'http:\/\/210.14.75.1:9980'   \u8fd9\u91cc\u5e26\u7aef\u53e3\u53f7\uff0c\u514d\u53bb\u4fee\u6539\/var\/opt\/gitlab\/gitlab-rails\/etc\/gitlab.yml\u7684\u9ebb\u70e6\u3002 \ngitlab_rails&#091;'gitlab_ssh_host'] = '210.14.75.1'\ngitlab_rails&#091;'gitlab_shell_ssh_port'] = 9922\ngitlab_rails&#091;'backup_keep_time'] = 604800<\/code><\/pre>\n\n\n\n<p>Tips\uff1anginx[&#8216;listen_port&#8217;]\u4e0d\u8bbe\u7f6e\uff0c NGINX \u5c06\u4fa6\u542c external_url \u4e2d\u6307\u5b9a\u7684\u7aef\u53e3\u6216\u9690\u5f0f\u4f7f\u7528\u6b63\u786e\u7684\u7aef\u53e3\uff08HTTP \u4e3a 80\uff0cHTTPS \u4e3a 443\uff09\u3002<\/p>\n\n\n\n<p>backup_keep_time: \u5728\u5141\u8bb8\u5220\u9664\u5907\u4efd\u4e4b\u524d\u4fdd\u7559\u5907\u4efd\u7684\u6301\u7eed\u65f6\u95f4\uff08\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff09,604800\u662f7\u5929<\/p>\n\n\n\n<p>\u4fee\u6539\u914d\u7f6e\u540e\u91cd\u542f\u5bb9\u5668<\/p>\n\n\n\n<p>\u8bbf\u95ee<a href=\"http:\/\/125.74.48.123:8080\/users\/sign_in\">http:\/\/210.14.75.1:9980\/users\/sign_in<\/a> \u5c31\u53ef\u4ee5\u6253\u5f00\u9875\u9762\u4e862.\/var\/opt\/gitlab\/gitlab-rails\/etc\/gitlab.yml \u6587\u4ef6\u914d\u7f6e<\/p>\n\n\n\n<p>\u5f53\u65f6\u6211\u5df2\u7ecf\u521b\u5efa\u4e86\u9879\u76ee\uff0c\u5728\u9879\u76ee\u8be6\u60c5\u9875\u590d\u5236\u4e86\u9879\u76ee\u5730\u5740\uff0c\u4e00\u76f4\u4e0b\u8f7d\u4e0d\u4e0b\u6765\uff0c\u53d1\u73b0\u8be6\u60c5\u9875\u663e\u793a\u7684\u6ca1\u6709\u5e26\u7aef\u53e3\u53f7\uff0c\u5b9e\u9645\u514b\u9686\u7684\u65f6\u5019\u9700\u8981\u7aef\u53e3\u53f7\u7684\uff0c\u5982\uff1a<a href=\"http:\/\/125.74.48.123:8080\/root\/test_project.git\">http:\/\/210.14.75.1:9980\/root\/test_project.git<\/a><\/p>\n\n\n\n<p>\u8fd9\u4e2a\u662f\u8981\u6211\u4eec\u4fee\u6539\/var\/opt\/gitlab\/gitlab-rails\/etc\/gitlab.yml\u7684\u7aef\u53e3<\/p>\n\n\n\n<p>\u4fee\u6539\u6620\u5c04\u540e\u7684\u6587\u4ef6\/mydata\/gitlab\/opt\/gitlab-rails\/etc\/gitlab.yml\uff0c\u4fee\u6539\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> ## GitLab settings\n  gitlab:\n    ## Web server settings (note: host is the FQDN, do not include http:\/\/)\n    host: 210.14.75.1\n    port: 9980\n    https: false<\/code><\/pre>\n\n\n\n<p>\u8fdb\u5165\u5bb9\u5668<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it gitlab \/bin\/bash<\/code><\/pre>\n\n\n\n<p>\u91cd\u542f\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gitlab-ctl restart<\/code><\/pre>\n\n\n\n<p>Tips\uff1a\u6ce8\u610f\u8fd9\u91cc\u7684\u547d\u4ee4\u662frestart\u4e0d\u662f<strong><em>reconfigure(\u6839\u636e\u914d\u7f6e\u6587\u4ef6\/etc\/gitlab\/gitlab.rb \u91cd\u65b0\u751f\u6210\u914d\u7f6e)<\/em><\/strong>\uff0c\u5426\u5219\u8fd8\u4f1a\u6062\u590d\u539f\u6765\u7684\u914d\u7f6e\u3002\u53ea\u8981\u6267\u884c\u4e86gitlab-ctl reconfigure,gitlab.yml\u4e2d\u7684\u7aef\u53e3\u914d\u7f6e\u5c31\u4f1a\u88ab\u8fd8\u539f\u3002\u6240\u4ee5\u5982\u679c\u4f60\u91cd\u542f\u4e86\u5bb9\u5668\u4e4b\u540e\uff0c\u90a3\u8fd9\u91cc\u7684\u7aef\u53e3\u5c31\u53c8\u9700\u8981\u6539\u4e00\u904d\u3002<\/p>\n\n\n\n<p>\u91cd\u542f\u540e\u9000\u51fa\u5bb9\u5668<\/p>\n\n\n\n<p>\u4e09\u3001\u505a\u5b9a\u65f6\u5907\u4efd<\/p>\n\n\n\n<p>docker\u65b9\u5f0f\u5b89\u88c5\u7684\u6267\u884c\u5907\u4efd\u7684\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec gitlab gitlab-backup create  #gitlab\u662f\u5bb9\u5668\u7684\u540d\u79f0<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0\u5b9a\u65f6\u4efb\u52a1\uff1a<\/p>\n\n\n\n<p>crontab -e \u5728\u6587\u672c\u4e2d\u6dfb\u52a0\u4e0b\u9762\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0 23 * * * docker exec gitlab gitlab-backup create<\/code><\/pre>\n\n\n\n<p>\u5907\u4efd\u7684\u76ee\u5f55\u8def\u5f84\u5728\uff1a<\/p>\n\n\n\n<p>\/mydata\/gitlab\/opt\/backups<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@ubuntu:~# tree -L 1 \/mydata\/gitlab\/opt\/backups\/\n\/mydata\/gitlab\/opt\/backups\/\n\u2514\u2500\u2500 1710314270_2024_03_13_16.3.3_gitlab_backup.tar<\/code><\/pre>\n\n\n\n<p>\u56db\u3001\u8fd8\u539f\u5907\u4efd<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it gitlab \/bin\/bash\ncd \/var\/opt\/gitlab\/backups\ngitlab-ctl stop puma\ngitlab-ctl stop sidekiq\ngitlab-ctl status\ngitlab-rake gitlab:backup:restore BACKUP=1710314270_2024_03_13_16.3.3<\/code><\/pre>\n\n\n\n<p>Tips:&nbsp; \u6ce8\u610f\u8fd9\u91cc\u4e0d\u8981\u5e26_gitlab_backup.tar\u540e\u7f00\uff0c\u8fd8\u539f\u7684\u65f6\u5019\u7248\u672c\u9700\u8981\u662f\u4e00\u81f4\u7684<\/p>\n\n\n\n<p>Tips\uff1a\u62a5\u9519\u4fe1\u606f\uff1aRestoring PostgreSQL database gitlabhq_production &#8230; ERROR:&nbsp;&nbsp;must be owner of extension pg_trgm<\/p>\n\n\n\n<p>ERROR:&nbsp;&nbsp;must be owner of extension btree_gist<\/p>\n\n\n\n<p>ERROR:&nbsp;&nbsp;must be owner of extension btree_gist<\/p>\n\n\n\n<p>ERROR:&nbsp;&nbsp;must be owner of extension pg_trgm<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it gitlab \/bin\/bash\n# \u4fee\u6539\u4ee5\u4e0b\u914d\u7f6e\u6587\u4ef6\uff0c\u4fee\u6539\u7aef\u53e3\u76d1\u542c\u5730\u5740,\u9ed8\u8ba4\u76d1\u63a7localhost\uff0c* \u4ee3\u8868all\n$ vim \/var\/opt\/gitlab\/postgresql\/data\/postgresql.conf\nlisten_addresses = '*'\n# \u4ee5\u4e0b\u914d\u7f6e\u6587\u4ef6\u672b\u5c3e\u65b0\u589e\u4ee5\u4e0b\u4e24\u884c\n$ vim \/var\/opt\/gitlab\/postgresql\/data\/pg_hba.conf\nlocal   all         all                               trust\nhost    all         all                               127.0.0.1\/32 trust\n\n\n#\u91cd\u542fgitlab\u670d\u52a1\ngitlab-ctl restart\n\n\n$ su - gitlab-psql\n$ \/opt\/gitlab\/embedded\/bin\/psql -h 127.0.0.1 gitlabhq_production\ngitlabhq_production=# ALTER USER gitlab WITH SUPERUSER;\nALTER ROLE\ngitlabhq_production=# \\q\n$ exit<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u62c9\u53d6\u955c\u50cf \u4e8c\u3001\u542f\u52a8\u5bb9\u5668 etc\u6620\u5c04\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6\uff0clog\u5b58\u50a8\u65e5\u5fd7\uff0cdata\u5b58\u653e\u6570\u636e\u6587\u4ef6 \u4e09\u3001gitlab\u76f8\u5173\u914d\u7f6e 1\u3001\u914d\u7f6e\u5bb9\u5668\u4e2d\u7684\/etc\/gitlab\/gitlab.rb\u7684\u914d\u7f6e\u6587\u4ef6 \u6211\u4eec\u6253\u5f00\u6620\u5c04\u6587\u4ef6\/mydata\/gitlab\/etc\/gitlab.rb\u5c31\u53ef\u4ee5\u4fee\u6539\uff0c\u4fee\u6539\u7684\u5185\u5bb9\u5982\u4e0b\uff1a Tips\uff1anginx[&#8216;listen_port&#8217;]\u4e0d\u8bbe\u7f6e\uff0c NGINX \u5c06\u4fa6\u542c external_url \u4e2d\u6307\u5b9a\u7684\u7aef\u53e3\u6216\u9690\u5f0f\u4f7f\u7528\u6b63\u786e\u7684\u7aef\u53e3\uff08HTTP \u4e3a 80\uff0cHTTPS \u4e3a 443\uff09\u3002 backup_keep_time: \u5728\u5141\u8bb8\u5220\u9664\u5907\u4efd\u4e4b\u524d\u4fdd\u7559\u5907\u4efd\u7684\u6301\u7eed\u65f6\u95f4\uff08\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff09,604800\u662f7\u5929 \u4fee\u6539\u914d\u7f6e\u540e\u91cd\u542f\u5bb9\u5668 \u8bbf\u95eehttp:\/\/210.14.75.1:9980\/users\/sign_in \u5c31\u53ef\u4ee5\u6253\u5f00\u9875\u9762\u4e862.\/var\/opt\/gitlab\/gitlab-rails\/etc\/gitlab.yml \u6587\u4ef6\u914d\u7f6e \u5f53\u65f6\u6211\u5df2\u7ecf\u521b\u5efa\u4e86\u9879\u76ee\uff0c\u5728\u9879\u76ee\u8be6\u60c5\u9875\u590d\u5236\u4e86\u9879\u76ee\u5730\u5740\uff0c\u4e00\u76f4\u4e0b\u8f7d\u4e0d\u4e0b\u6765\uff0c\u53d1\u73b0\u8be6\u60c5\u9875\u663e\u793a\u7684\u6ca1\u6709\u5e26\u7aef\u53e3\u53f7\uff0c\u5b9e\u9645\u514b\u9686\u7684\u65f6\u5019\u9700\u8981\u7aef\u53e3\u53f7\u7684\uff0c\u5982\uff1ahttp:\/\/210.14.75.1:9980\/root\/test_project.git \u8fd9\u4e2a\u662f\u8981\u6211\u4eec\u4fee\u6539\/var\/opt\/gitlab\/gitlab-rails\/etc\/gitlab.yml\u7684\u7aef\u53e3 \u4fee\u6539\u6620\u5c04\u540e\u7684\u6587\u4ef6\/mydata\/gitlab\/opt\/gitlab-rails\/etc\/gitlab.yml\uff0c\u4fee\u6539\u4e3a\uff1a \u8fdb\u5165\u5bb9\u5668 \u91cd\u542f\u670d\u52a1 Tips\uff1a\u6ce8\u610f\u8fd9\u91cc\u7684\u547d\u4ee4\u662frestart\u4e0d\u662freconfigure(\u6839\u636e\u914d\u7f6e\u6587\u4ef6\/etc\/gitlab\/gitlab.rb \u91cd\u65b0\u751f\u6210\u914d\u7f6e)\uff0c\u5426\u5219\u8fd8\u4f1a\u6062\u590d\u539f\u6765\u7684\u914d\u7f6e\u3002\u53ea\u8981\u6267\u884c\u4e86gitlab-ctl reconfigure,gitlab.yml\u4e2d\u7684\u7aef\u53e3\u914d\u7f6e\u5c31\u4f1a\u88ab\u8fd8\u539f\u3002\u6240\u4ee5\u5982\u679c\u4f60\u91cd\u542f\u4e86\u5bb9\u5668\u4e4b\u540e\uff0c\u90a3\u8fd9\u91cc\u7684\u7aef\u53e3\u5c31\u53c8\u9700\u8981\u6539\u4e00\u904d\u3002 \u91cd\u542f\u540e\u9000\u51fa\u5bb9\u5668 \u4e09\u3001\u505a\u5b9a\u65f6\u5907\u4efd docker\u65b9\u5f0f\u5b89\u88c5\u7684\u6267\u884c\u5907\u4efd\u7684\u547d\u4ee4\uff1a \u6dfb\u52a0\u5b9a\u65f6\u4efb\u52a1\uff1a crontab -e \u5728\u6587\u672c\u4e2d\u6dfb\u52a0\u4e0b\u9762\u5185\u5bb9\uff1a \u5907\u4efd\u7684\u76ee\u5f55\u8def\u5f84\u5728\uff1a \/mydata\/gitlab\/opt\/backups \u56db\u3001\u8fd8\u539f\u5907\u4efd Tips:&nbsp; \u6ce8\u610f\u8fd9\u91cc\u4e0d\u8981\u5e26_gitlab_backup.tar\u540e\u7f00\uff0c\u8fd8\u539f\u7684\u65f6\u5019\u7248\u672c\u9700\u8981\u662f\u4e00\u81f4\u7684 Tips\uff1a\u62a5\u9519\u4fe1\u606f\uff1aRestoring PostgreSQL database gitlabhq_production &#8230; ERROR:&nbsp;&nbsp;must be owner of extension pg_trgm ERROR:&nbsp;&nbsp;must be owner [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-433","post","type-post","status-publish","format-standard","hentry","category-dockerkubernetes"],"_links":{"self":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=433"}],"version-history":[{"count":3,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":617,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/433\/revisions\/617"}],"wp:attachment":[{"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opshub.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}