Docker deployment of gitlab in Ubuntu environment

docker run \
 -itd  \
 -p 9980:80 \
 -p 9922:22 \
 -v /home/gitlab/etc:/etc/gitlab  \
 -v /home/gitlab/log:/var/log/gitlab \
 -v /home/gitlab/opt:/var/opt/gitlab \
 --restart always \
 --privileged=true \
 --name gitlab \
 gitlab/gitlab-ce

Document address: https://docs.gitlab.com/ee/install/docker.html

Create a new file: docker-compose.yml

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  tty: true
  hostname: 'gitlab.example.com'
  ports:
    - '8000:8000'
    - '2224:22'
  environment:
    TZ: "Asia/Shanghai"
    GITLAB_OMNIBUS_CONFIG: |
      external_url "http://gitlab.example.com:8000"
      postgresql['shared_buffers'] = "256MB"
      sidekiq['concurrency'] = 4
      prometheus_monitoring['enable'] = false
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'
#sudo docker-compose up -d (start gitlab service)

#sudo docker-compose down (stop gitlab and delete the project)

Note that docker-compose commands need to be executed in the same directory as docker-compose.yml

At this point the project is started, and then open 127.0.0.1:8929 (the IP here should be the server id deployed by gitlab)

Note that it may take dozens of seconds for the browser to open after the project is started, and sometimes a 502 may appear after opening.

If a 502 error occurs, clear the browser cache and refresh the page, and it should be fine.

3. View logs: #sudo docker logs -f -t --tail=10 container_name
-f : View real-time logs

-t: View the date the log was generated

-tail=10: View the last 10 logs.

container_name: container name

4. Open the browser xx.xx.xx:8929


This is not to set the password for the root account as mentioned on the Internet, but to directly enter the username and password, but I don’t know the username and password. So here I searched all over Baidu, and the only way was to change the password, and in the end I could only Bite the bullet.

5. Modify the root password
1. View the running container ID

#sudo docker ps 

2. Enter the container

#sudo docker exec -it Public ID /bin/bash

3. Enter the bin directory of gitlab

# cd /opt/gitlab/bin

4. Execute gitlab-rails console (note that there is no production mentioned on the Internet here, you can try it, haha~~)

#gitlab-rails console

 At least if you can enter the gitlab container, the above operations will not go wrong.

5. Find the root user and enter u=User.where(id:1).first (because the root user’s ID is the default user and the ID is 1)

 irb(main):001:0> u=User.where(id:1).first

=> #<User id:1 @root>

6. Modify password and enter u.password='12345678'

irb(main):002:0> u.password='12345678'
=> "12345678"

7. Change the confirmation password

irb(main):004:0> u.password_confirmation='12345678'
=> "12345678"

8. To save the changes, enter u.save, then press Enter, and wait until true is output. At this time, the password is changed successfully.

irb(main):005:0> u.save
xxxxxxxx (a lot of information)
=> true

[Original address]( Docker deployment in Ubuntu environment gitlab_ubuntu docker gitlab_Only glaze's blog-CSDN blog )

Guess you like

Origin blog.csdn.net/zhuweideng/article/details/130001001