首先需準備好ssl憑證,這部分可參考Let’s Encrypt
建立conf,data,log,ssl等資料夾於$PWD/files之下.
mkdir -p $PWD/files/conf
mkdir -p $PWD/files/log
mkdir -p $PWD/files/data
mkdir -p $PWD/files/ssl
並把fullchain.pem以及private.pem放在$PWD/files/ssl資料夾下,
接著用下列語法,就可以用docker架設gitlab server了
docker run -d \
--name=gitlab \
--hostname git.slanla.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'https://git.slanla.com' ; nginx['redirect_http_to_https'] = true" ; gitlab_rails['backup_keep_time'] = 604800 ; \
--publish 443:443 \
--publish 80:80 \
--restart always \
-v $PWD/files/ssl/fullchain.pem:/etc/gitlab/ssl/git.slanla.com.crt \
-v $PWD/files/ssl/privkey.pem:/etc/gitlab/ssl/git.slanla.com.key \
-v $PWD/files/conf:/etc/gitlab \
-v $PWD/files/log:/var/log/gitlab \
-v $PWD/files//data:/var/opt/gitlab \
gitlab/gitlab-ce:10.1.0-ce.0
其中
--hostname git.slanla.com \
--env GITLAB_OMNIBUS_CONFIG="external_url 'https://git.slanla.com';nginx['redirect_http_to_https'] = true" \
--publish 443:443 \
-v $PWD/files/ssl/fullchain.pem:/etc/gitlab/ssl/git.slanla.com.crt \
-v $PWD/files/ssl/privkey.pem:/etc/gitlab/ssl/git.slanla.com.key \
是與https相關,若不需要則可移除.