sameersbn / docker-gitlab

Dockerized GitLab
http://www.damagehead.com/docker-gitlab/
MIT License
7.91k stars 2.14k forks source link

Getting dockergitlab_gitlab_1 exited with code 1 #1805

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi I am trying to connect the gitlab with external mysql using docker-compose. But getting the error dockergitlab_gitlab_1 exited with code 1 when i run docker-compose up and its keeps on repeating.

Below is my docker-compose.yaml

version: '2'
services:
  redis:
    restart: always
    image: sameersbn/redis:latest
    command:
    - --loglevel warning
    volumes:
    - /srv/docker/gitlab/redis:/var/lib/redis:Z
  gitlab:
    restart: always
    image: sameersbn/gitlab:11.5.1
    depends_on:
    - redis    
    ports:
    - "10080:80"
    - "10022:22"
  volumes:
    - /srv/docker/gitlab/gitlab:/home/git/data:Z
    environment:
    - DEBUG=true
    - DB_ADAPTER=mysql2
    - DB_HOST=ip address of mysql
    - DB_PORT=3306
    - DB_USER=gitlab
    - DB_PASS=password
    - DB_NAME=gitlabhq_production
    - REDIS_HOST=redis
    - REDIS_PORT=6379
    - TZ=Asia/Kolkata
    - GITLAB_TIMEZONE=Kolkata
    - GITLAB_HTTPS=false
    - SSL_SELF_SIGNED=false
    - GITLAB_HOST=localhost
    - GITLAB_PORT=10080
    - GITLAB_SSH_PORT=10022
    - GITLAB_RELATIVE_URL_ROOT=
    - GITLAB_SECRETS_DB_KEY_BASE=d464ce478a298a3843879a27e5849c0bf8d176e63570dfcf8941ba7484025b3d
    - GITLAB_SECRETS_SECRET_KEY_BASE=803b413fcf537468fcda4b7844a1c9f57e49edb3d655b2e6b24f448a083653f3
    - GITLAB_SECRETS_OTP_KEY_BASE=4fe745b89be6a40748ec24e4a765646b93fd29c1830bdd2f675adb7559212ab3

    - GITLAB_ROOT_PASSWORD=admin
    - GITLAB_ROOT_EMAIL=
    - GITLAB_NOTIFY_ON_BROKEN_BUILDS=true
    - GITLAB_NOTIFY_PUSHER=false

    - GITLAB_EMAIL=operations@mail.com
    - GITLAB_EMAIL_REPLY_TO=noreply@example.com
    - GITLAB_INCOMING_EMAIL_ADDRESS=reply@example.com

    - GITLAB_BACKUP_SCHEDULE=daily
    - GITLAB_BACKUP_TIME=01:00

    - IMAP_ENABLED=false
    - IMAP_HOST=imap.gmail.com
    - IMAP_PORT=993
    - IMAP_USER=mailer@example.com
    - IMAP_PASS=password
    - IMAP_SSL=true
    - IMAP_STARTTLS=false

    - OAUTH_ENABLED=false
    - OAUTH_AUTO_SIGN_IN_WITH_PROVIDER=
    - OAUTH_ALLOW_SSO=
    - OAUTH_BLOCK_AUTO_CREATED_USERS=true
    - OAUTH_AUTO_LINK_LDAP_USER=false
    - OAUTH_AUTO_LINK_SAML_USER=false
    - OAUTH_EXTERNAL_PROVIDERS=

    - OAUTH_CAS3_LABEL=cas3
    - OAUTH_CAS3_SERVER=
    - OAUTH_CAS3_DISABLE_SSL_VERIFICATION=false
    - OAUTH_CAS3_LOGIN_URL=/cas/login
    - OAUTH_CAS3_VALIDATE_URL=/cas/p3/serviceValidate
    - OAUTH_CAS3_LOGOUT_URL=/cas/logout

`

Tried the below command as wel docker run --name gitlab -d \ --env 'DB_ADAPTER=mysql2' --env 'DB_HOST=mysql_IP' \ --env 'DB_NAME=gitlabhq_production' \ --env 'DB_PORT=3306' \ --env 'DB_USER=gitlab' --env 'DB_PASS=password' \ --volume /srv/docker/gitlab/gitlab:/home/git/data \ sameersbn/gitlab:latest

but getting like below

Loading /etc/docker-gitlab/runtime/env-defaults Initializing logdir... Initializing datadir... Installing configuration templates... Configuring gitlab... Configuring gitlab::database...........................................................

ghost commented 5 years ago

any update on this?

frenchbeard commented 5 years ago

Could you try to launch through "docker run" with --env 'DEBUG=true' as well, considering the information on the error Gitlab ran into is not displayed there ?

ghost commented 5 years ago

After enabling the --env 'DEBUG=true getting like

+ export GITLAB_INSTALL_DIR GITLAB_SHELL_INSTALL_DIR GITLAB_DATA_DIR GITLAB_REPOS_DIR GITLAB_DOWNLOADS_DIR GITLAB_SHARED_DIR GITLAB_HOST GITLAB_PORT GITLAB_RELATIVE_URL_ROOT GITLAB_HTTPS GITLAB_SSH_HOST GITLAB_SSH_PORT GITLAB_SIGNUP_ENABLED GITLAB_PROJECTS_LIMIT GITLAB_USERNAME_CHANGE GITLAB_CREATE_GROUP
+ local IFS=:
+ sudo -HEu git envsubst '$GITLAB_INSTALL_DIR:$GITLAB_SHELL_INSTALL_DIR:$GITLAB_DATA_DIR:$GITLAB_REPOS_DIR:$GITLAB_DOWNLOADS_DIR:$GITLAB_SHARED_DIR:$GITLAB_HOST:$GITLAB_PORT:$GITLAB_RELATIVE_URL_ROOT:$GITLAB_HTTPS:$GITLAB_SSH_HOST:$GITLAB_SSH_PORT:$GITLAB_SIGNUP_ENABLED:$GITLAB_PROJECTS_LIMIT:$GITLAB_USERNAME_CHANGE:$GITLAB_CREATE_GROUP'
+ rm -f /tmp/tmp.fJRiqAUhiC
+ gitlab_configure_database
+ echo -n 'Configuring gitlab::database'
+ gitlab_finalize_database_parameters
+ [[ -n '' ]]
+ [[ -n '' ]]
+ [[ -z localhost ]]
+ DB_ADAPTER=mysql2
+ case ${DB_ADAPTER} in
+ DB_ENCODING=utf8
+ DB_COLLATION=utf8_general_ci
+ DB_PORT=3306
+ DB_USER=gitlab
+ DB_NAME=gitlabhq_production
+ gitlab_check_database_connection
+ case ${DB_ADAPTER} in
+ prog='mysqladmin -h localhost -P 3306 -u gitlab -p password status'
+ timeout=60
+ mysqladmin -h localhost -P 3306 -u gitlab -p password status
++ expr 60 - 1
+ timeout=59
+ [[ 59 -eq 0 ]]
+ echo -n .
+ sleep 1
+ mysqladmin -h localhost -P 3306 -u gitlab -p password status
++ expr 59 - 1
+ timeout=58
+ [[ 58 -eq 0 ]]
+ echo -n .
+ sleep 1
+ mysqladmin -h localhost -P 3306 -u gitlab -p password status
++ expr 58 - 1
+ timeout=57
+ [[ 57 -eq 0 ]]
+ echo -n .
+ sleep 1
+ mysqladmin -h localhost -P 3306 -u gitlab -p password status
++ expr 57 - 1
+ timeout=56
+ [[ 56 -eq 0 ]]
+ echo -n .
+ sleep 1
+ mysqladmin -h localhost -P 3306 -u gitlab -p password status
++ expr 56 - 1
+ timeout=55
+ [[ 55 -eq 0 ]]
+ echo -n .
    .
    .
    .

    + mysqladmin -h localhost -P 3306 -u gitlab -ppassword status
    ++ expr 1 - 1
    + timeout=0
    Configuring gitlab::database...........................................................

` then container exited.

solidnerd commented 5 years ago

Hey @Beanben,

your problem is that you try to use localhost for your database this won't work in container execept your brake up the network isolation. By default every container has it's own localhost.

So to fix that use the external IP of your database and ensure that the connection from your container is allowed.

solidnerd commented 5 years ago

If the error still exists please reopen the issue.

ghost commented 5 years ago

Yes i agree, but even after providing the database host name also its same. Can you please tell me where am i doing wrong. Is my docker-compose.yml correct.

nongzhi9950 commented 5 years ago

I meet the same issue , I think the sameersbn/gitlab:latest image is corrupt and Can't work at all ,it's rubbish.

PittRo commented 5 years ago

I meet the same issue with an older image sameersbn/gitlab:7.14.3 via GITLAB_OMNIBUS_CONFIG I don't get any database-connection. If I try a seperatly mysql/postgresql-image gitlab start's before mysql or postgresql is ready. Every solved issue here worked not out https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y