docker-gitlab icon indicating copy to clipboard operation
docker-gitlab copied to clipboard

Linked MySQL container leaves Gitlab 'Waiting for database server to accept connections'

Open pirelenito opened this issue 12 years ago • 17 comments

Hi,

I've followed the tutorial on how to setup an environment with MySQL, but it is not working. I've tried different versions (including the most recent one 7.3.2) still with no success.

Here is the script I am trying to run:

docker pull sameersbn/redis:latest
docker run -i -t -d \
       --name=ci-gitlab-redis \
       sameersbn/redis:latest

docker pull sameersbn/mysql:latest
docker run -i -t -d \
       -v /data/ci-gitlab-mysql/data:/var/lib/mysql \
       -e 'DB_NAME=gitlabhq_production' \
       -e 'DB_USER=gitlab' \
       -e 'DB_PASS=password'\
       --name=ci-gitlab-mysql \
       sameersbn/mysql:latest

docker pull sameersbn/gitlab:7.3.2
docker run -i -t -d \
       -p 80 -p 22:2222 \
       --link ci-gitlab-redis:redisio \
       --link ci-gitlab-mysql:mysql \
       -v /data/ci-gitlab/data:/home/git/data \
       -e "GITLAB_HOST=git.local.bravi.com.br" \
       -e "VIRTUAL_HOST=git.local.bravi.com.br" \
       -e "VIRTUAL_PORT=80" \
       --name ci-gitlab \
       sameersbn/gitlab:7.3.2

Here are the MySQL Logs:

vagrant@continuous-integration:/opt/continuous-integration$ docker logs ci-gitlab-mysql
Creating database "gitlabhq_production"...
Granting access to database "gitlabhq_production" for user "gitlab"...
141001 17:34:31 mysqld_safe Logging to syslog.
141001 17:34:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

And the GitLab container logs:

vagrant@continuous-integration:/opt/continuous-integration$ docker logs ci-gitlab
Starting cron...
Starting openssh server...
Starting nginx...
Waiting for database server to accept connections...
Waiting for database server to accept connections...
Waiting for database server to accept connections...
Waiting for database server to accept connections...
Waiting for database server to accept connections...
Waiting for database server to accept connections...

And I can confirm that when starting the GitLab image with a bash I can connect to the MySQL database.

vagrant@continuous-integration:/opt/continuous-integration$ docker run -i -t \
                                    --link ci-gitlab-redis:redisio \
                                    --link ci-gitlab-mysql:mysql \
                                    -v /data/ci-gitlab/data:/home/git/data \
                                    -e "GITLAB_HOST=git.local.bravi.com.br" \
                                    -e "VIRTUAL_HOST=git.local.bravi.com.br" \
                                    -e "VIRTUAL_PORT=80" \
                                    sameersbn/gitlab:7.3.1-3 \
                                    /bin/bash

root@942631a2987a:/home/git/gitlab# env
REDISIO_PORT_6379_TCP_PROTO=tcp
HOSTNAME=942631a2987a
MYSQL_ENV_DB_PASS=password
MYSQL_ENV_DEBIAN_FRONTEND=noninteractive
TERM=xterm
REDISIO_NAME=/focused_lumiere/redisio
VIRTUAL_PORT=80
REDISIO_PORT_6379_TCP_ADDR=172.17.0.19
MYSQL_PORT_3306_TCP_PORT=3306
REDISIO_PORT_6379_TCP_PORT=6379
MYSQL_PORT_3306_TCP=tcp://172.17.0.20:3306
MYSQL_ENV_DB_USER=gitlab
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MYSQL_ENV_DB_NAME=gitlabhq_production
PWD=/home/git/gitlab
REDISIO_PORT_6379_TCP=tcp://172.17.0.19:6379
REDISIO_PORT=tcp://172.17.0.19:6379
HOME=/
SHLVL=2
GITLAB_HOST=git.local.bravi.com.br
MYSQL_PORT_3306_TCP_PROTO=tcp
MYSQL_NAME=/focused_lumiere/mysql
MYSQL_PORT_3306_TCP_ADDR=172.17.0.20
DEBIAN_FRONTEND=noninteractive
REDISIO_ENV_DEBIAN_FRONTEND=noninteractive
VIRTUAL_HOST=git.local.bravi.com.br
MYSQL_PORT=tcp://172.17.0.20:3306
_=/usr/bin/env

root@942631a2987a:/home/git/gitlab# mysql -h 172.17.0.20 -u gitlab -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.39-1 (Debian)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

I've been strugling with this for the past couple of hours and can't seem to find something with my setup.

Could this be a bug with the MySQL link feature?

ps: Thanks for the great work you've been doing with this image! :)

pirelenito avatar Oct 01 '14 18:10 pirelenito

I found the issue.

The init script inside the Docker image seems to be outdated. Manually editing inside the container with the latest changes from master seems to fix the problem.

pirelenito avatar Oct 01 '14 19:10 pirelenito

@pirelenito thats weird. Maybe I didn't build the tag properly. Rebuilding the tag now.

sameersbn avatar Oct 01 '14 20:10 sameersbn

Hi @sameersbn

Actually I just discovered that the init is updated in 7.3.2. I accidentally ran an old version while doing the testing (I was doing a lot of back and forward between versions while debugging this issue).

You can check on the issue description, I was actually running sameersbn/gitlab:7.3.1-3.

Sorry about that.

In my testing if I use the sameersbn/gitlab:7.3.1-3 as a base image to use the updated init script I can make it work.

Here is the Dockerfile I am using:

FROM sameersbn/gitlab:7.3.1-3

# Override default init (which is broken)
# see: https://github.com/sameersbn/docker-gitlab/issues/167
ADD init /app/init
RUN chmod 755 /app/init

Unfortunately the 7.3.2 keeps with the 'Waiting for database server to accept connections'

But I managed to make it work for now.

Thanks for the quick response and sorry about my mistake :)

pirelenito avatar Oct 01 '14 20:10 pirelenito

@pirelenito can you try the mysqladmin -h ${DB_HOST} -u ${DB_USER} -p$DB_PASS} status command from the gitlab container? of course update the host, user and pass in the command

sameersbn avatar Oct 01 '14 20:10 sameersbn

@pirelenito I think I need to install the mysql-client package.

sameersbn avatar Oct 01 '14 21:10 sameersbn

@pirelenito can you try the 7.3.2-1 release. It is currently being built and should be ready in about 30 mins

sameersbn avatar Oct 01 '14 21:10 sameersbn

Hi there,

I had the same problem, pulled :latest tag about four hours ago, and kept getting the error message. The container was missing the mysqladmin binary.

And yes, I can confirm version 7.3.2-1 working.

cheers ~stesie

stesie avatar Oct 01 '14 22:10 stesie

Hi @sameersbn

I can confirm that the release 7.3.2-1 is working.

Thanks!

pirelenito avatar Oct 02 '14 22:10 pirelenito

i have the same problem that release 7.6.1

YauzZ avatar Dec 27 '14 16:12 YauzZ

@YauzZ can you please paste your docker run command for starting mysql and gitlab containers? This generally happens when the mysql connectio parameters are incorrect.

sameersbn avatar Dec 31 '14 16:12 sameersbn

@sameersbn i have solved. but i forgot what i do. sorry!

YauzZ avatar Feb 14 '15 04:02 YauzZ

this problem bit me too! I installed the mariadb-server (since i have changed the base image from ubuntu to centos the mysqladmin cmd was not found)

yum -y install mariadb-server

solved it

dobsiin avatar Jun 12 '15 10:06 dobsiin

I've a similar problem with gitlab and mysql. Initially I've created the docker containers in a Virtual machine on windows host, at that time gitlab used to work fine when running the virtualbox as admin. I was using a shared folder to virtualbox as mount to the docker volumes.

I recently moved my virtual machines to Linux (Ubuntu host with Oracle Virtual box). All the other containers are working just fine but for the gitlab. I've redmine, mysql, gitlab, redis, docker-registry containers in this set-up and all of them except for gitlab are working.

With gitlab, the push to existing repos is working from the files per say, I could confirm by looking into the mounted virtualbox share folder and checking the date the files got updated. But the changes are not reflected in the mysql database data folders / innodb files. Also, the updates are not reflected in the gitlab GUI. When I create a new repository, it is getting created properly in the filesystem, but the new project is not listed in the UI.

I ran the following command from my gitlab container, and following is the status: <mysqladmin -h ${MYSQL_PORT_3306_TCP_ADDR} -u ${DB_USER} -p${DB_PASS} status Uptime: 1415 Threads: 2 Questions: 741 Slow queries: 0 Opens: 99 Flush tables: 1 Open tables: 92 Queries per second avg: 0.523

The ${DB_HOST} is coming empty. Hence used the other value:MYSQL_PORT_3306_TCP_ADDR Also. The correct IP is present in the database.yml file (I've cross checked this).

I don't see any error messages anywhere in the /var/log/gitlab and its sub-directories. Need your help. Kindly suggest what I can do.

phani1kumar avatar Oct 20 '15 20:10 phani1kumar

you will need to take a look at the logs in /var/log/gitlab

sameersbn avatar Oct 21 '15 06:10 sameersbn

hi @sameersbn, just posted it as a new issue, because it is not 100% the same as this one. Also, provided more details about my issue in the issue #477

phani1kumar avatar Oct 21 '15 06:10 phani1kumar

Hello all, Can any one explain how to handle databases for CI? I am very new to gitlab and need some tutorial / guide to process the same. If any one can help me on this it will be very helpful. :+1: @pirelenito

anishTPM avatar Mar 10 '17 14:03 anishTPM

I use the docker runner and setup my database as a service:

variables:
  MYSQL_DATABASE: testing
  MYSQL_ROOT_PASSWORD: toor
  DEVELOPMENT: noprofile
unittesting:
  image: dockerwest/php-laravel:7.1
  services:
    - mysql:latest
  stage: testing
  before_script:
  - php -v
  - composer --version
  - git --version
  - ls -lah
  script:
   script:
    - composer install
    - cp .env.testing .env
    - php artisan key:generate
    - php artisan config:cache
    - php artisan env
    - php artisan migrate
    - php artisan db:seed
    - php vendor/bin/phpunit --colors

Pegasuz avatar Mar 10 '17 16:03 Pegasuz