3.1 下载安装redis:

sudo docker pull sameersbn/redis:latest

Docker启动redis:

docker run --name=redis -d \
-v /home/docker/opt/redis/data:/var/lib/redis \
sameersbn/redis:latest

或者:(\表示换行连接)

docker run -p 6379:6379 \
-v /home/docker/opt/redis/data:/var/lib/redis \  
-d redis:latest \
redis-server --appendonly yes

测试安装配置结果:

docker run -it redis:latest redis-cli -h 114.55.93.240
127.0.0.1> info

3.2 下载安装postgresql:

mkdir /home/gitlab/opt/postgresql/data
sudo docker pull sameersbn/postgresql:9.6

启动生成postgresql镜像容器:

阿里云-推广AD
docker run --name=postgresql -d \
--restart always \
-e 'DB_NAME=gitlabhq_production' \
-e 'DB_USER=gitlab' \
-e 'DB_PASS=password' \
-v /home/gitlab/opt/postgresql/data:/var/lib/postgresql \
sameersbn/postgresql:9.6

注:记住安装目录

3.3 拉取下载GitLab(还可指定版本)

sudo mkdir /home/gitlab/opt/gitlab/data
sudo docker pull sameersbn/gitlab:10.6.0

Docker启动Gitlab并生成镜像容器:

docker run --name='gitlab' -d \
--privileged=true
--net container:redis
--link postgresql:postgresql \
--link redis:redisio \
--restart on-failure:3 \
-v /home/gitlab/data:/home/gitlab/data \
-m 2048m --memory-swap=-1 \
-p 10022:22 -p 10080:80 \
-e 'GITLAB_PORT=10080' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_HOST=git.4u4v.com' \
-e 'GITLAB_EMAIL=admin@4u4v.com' \
-e 'GITLAB_BACKUPS=daily' \
-e 'GITLAB_BACKUP_TIME=03:30' \
-e 'GITLAB_SIGNUP=true' \
-e 'GITLAB_GRAVATAR_ENABLED=false' \
sameersbn/gitlab:10.6.0   

注:将hostname替换为外网IP网上访问.