您的位置:首页 > 运维架构 > Docker

Docker安装Gitlab

2017-12-26 21:54 387 查看
1 查找镜像

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker search gitlab
INDEX       NAME                                                   DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/gitlab/gitlab-ce                             GitLab Community Edition docker image base...   1551                 [OK]
docker.io   docker.io/sameersbn/gitlab                             Dockerized gitlab web server                    977                  [OK]
docker.io   docker.io/gitlab/gitlab-runner                         GitLab CI Multi Runner used to fetch and r...   265                  [OK]
docker.io   docker.io/gitlab/gitlab-ee                             GitLab Enterprise Edition docker image bas...   74
docker.io   docker.io/twang2218/gitlab-ce-zh                       汉化的 GitLab 社区版 Docker Image                     70                   [OK]
2 安装

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker pull docker.io/gitlab/gitlab-ce
Using default tag: latest
Trying to pull repository docker.io/gitlab/gitlab-ce ...
latest: Pulling from docker.io/gitlab/gitlab-ce
50aff78429b1: Pull complete
f6d82e297bce: Pull complete
275abb2c8a6f: Pull complete
9f15a39356d6: Pull complete
fc0342a94c89: Pull complete
0764f17a9f6f: Pull complete
9e9f0daadcf5: Pull complete
37c49f52225d: Pull complete
80f507a7b28a: Pull complete
1a868e7edf8c: Pull complete
756dcda943b1: Pull complete
Digest: sha256:2e0ed65e0455322987549fadedd8ebfec1524fbb8b5151398ba742c672d93226


3 查看镜像

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
docker.io/gitlab/gitlab-ce   latest              fe264e19e6b8        3 days ago          1.39 GB


4 启动gitlab

docker run --detach \

     --hostname 139.196.144.147 \

     --publish 8443:443 --publish 80:80 --publish 2222:22 \

     --name gitlab \

     --restart always \

     --volume /home/gitlab/config:/etc/gitlab \

     --volume /home/gitlab/logs:/var/log/gitlab \

     --volume /home/gitlab/data:/var/opt/gitlab \
     docker.io/gitlab/gitlab-ce

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker run --detach \
>      --hostname 139.196.144.147 \
>      --publish 8443:443 --publish 80:80 --publish 2222:22 \
>      --name gitlab \
>      --restart always \
>      --volume /home/gitlab/config:/etc/gitlab \
>      --volume /home/gitlab/logs:/var/log/gitlab \
>      --volume /home/gitlab/data:/var/opt/gitlab \
>      docker.io/gitlab/gitlab-ce
/usr/bin/docker-current: Error response from daemon: Conflict. The name "/gitlab" is already in use by container ab4e5b2320277e1e786e9e95ab5a1d30a312619ffe71ea72458841430175800b. You have to remove (or rename) that container to be able to reuse that name..
See '/usr/bin/docker-current run --help'.
gitlab这个名称已经用了
[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker run --detach \
>      --hostname 139.196.144.147 \
>      --publish 8443:443 --publish 80:80 --publish 2222:22 \
>      --name gitlabce \
>      --restart always \
>      --volume /home/gitlab/config:/etc/gitlab \
>      --volume /home/gitlab/logs:/var/log/gitlab \
>      --volume /home/gitlab/data:/var/opt/gitlab \
>      docker.io/gitlab/gitlab-ce:latest
8b70ff9bfffd4403ce5f8b7f373363724d1df4fc2f25fc3ce6af9438480ec47a
5 检查启动
[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker ps
CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS                   PORTS                                                             NAMES
8b70ff9bfffd        docker.io/gitlab/gitlab-ce:latest   "/assets/wrapper"   2 minutes ago       Up 2 minutes (healthy)   0.0.0.0:80->80/tcp, 0.0.0.0:2222->22/tcp, 0.0.0.0:8443->443/tcp   gitlabce
过几分钟浏览器访问 http://139.196.144.147/

提示修改密码,默认用户是root

6 进入容器,查看版本

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker exec -it gitlabce  bash
root@139:/# git --version
git version 2.13.6
root@139:/# ruby --version
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
root@139:/# git --version
git version 2.13.6
root@139:/# redis-cli --version
redis-cli 3.2.11
root@139:/# psql --version
psql (PostgreSQL) 9.6.5


7 停止

[root@iZuf6boi8ejfovwda7q1ynZ ~]# docker stop gitlabce
gitlabce

要想使用原来的镜像名称,需要把创建的删除

删除 docker rm gitlab
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  docker