Skip to content
Advertisement

Maven Hangs Downloading Inside a Docker Container

I have a gitlab with gitlab ci and a runner all running fine in a CoreOs Machine.

All 3 services are running using the following dockerfiles service files and build script:

Build Script:

git submodule update --init

ls -la

mvn install

CI service:

    [Unit]
    Description=CI

    # Requirements
    Requires=docker.service
    Requires=db.service
    Requires=gitlab.service
    Requires=redis.service


    # Dependency ordering
    After=docker.service
    After=db.service
    After=gitlab.service
    After=redis.service

    [Service]
    User=core

    # Let the process take awhile to start up (for first run Docker containers)
    TimeoutStartSec=0

    # Get CoreOS environmental variables
    EnvironmentFile=/etc/environment

    # Pre-start and Start
    ## Directives with "=-" are allowed to fail without consequence
    KillMode=none
    Restart=always
    RestartSec=2

    ExecStartPre=-/usr/bin/docker kill ci
    ExecStartPre=-/usr/bin/docker rm ci
    ExecStartPre=/usr/bin/docker pull sameersbn/gitlab-ci:5.2.0
    ExecStart=/usr/bin/docker run --name ci 
     -e 'DB_TYPE=mysql' -e 'DB_HOST=${COREOS_PRIVATE_IPV4}' -e 'DB_NAME=***' -e 'DB_USER=***' -e 'DB_PASS=********'
     -e 'REDIS_HOST=${COREOS_PRIVATE_IPV4}' -e 'REDIS_PORT=6379'
     -e 'GITLAB_URL=http://${COREOS_PRIVATE_IPV4}:8081/'
     -e 'GITLAB_CI_HOST=${COREOS_PRIVATE_IPV4}'
     -e 'GITLAB_CI_PORT=8080'
     -e 'GITLAB_CI_HTTPS=true'
     -e 'GITLAB_CI_EMAIL=*****************'
     -e 'SMTP_USER=**********' -e 'SMTP_PASS=**********'
     -p 8080:80 
     sameersbn/gitlab-ci:5.2.0

    # Stop
    ExecStop=/usr/bin/docker stop ci

CI-runner service:

        [Unit]
        Description=CI Runner Maven & Dart

        # Requirements
        Requires=docker.service
        Requires=ci.service
        Requires=db.service
        Requires=gitlab.service
        Requires=redis.service

        # Dependency ordering
        After=docker.service
        After=ci.service
        After=db.service
        After=gitlab.service
        After=redis.service


        [Service]
        User=core

        # Let the process take awhile to start up (for first run Docker containers)
        TimeoutStartSec=0

        RemainAfterExit=yes

        # Get CoreOS environmental variables
        EnvironmentFile=/etc/environment

        #Pre-start and Start
        ## Directives with "=-" are allowed to fail without consequence

        ExecStartPre=-/usr/bin/docker kill ci-runner-maven-dart
        ExecStartPre=-/usr/bin/docker rm ci-runner-maven-dart
        ExecStartPre=/usr/bin/docker pull registry.globaleda.pt/globaleda/ci-runner-maven-dart:latest
        ExecStart=/usr/bin/docker run --name ci-runner-maven-dart -d 
            -v /data/ci-runner-maven-dart:/home/gitlab_ci_runner/data 
            registry.globaleda.pt/globaleda/ci-runner-maven-dart:latest

        # Stop
        ExecStop=/usr/bin/docker stop ci-runner-maven-dart

Ci runner dockerfile:

FROM lemonbar/gitlab-runner-jdk-maven:1.0
MAINTAINER jrofurtado@gmail.com

RUN apt-get update
RUN apt-get install curl -y

# Install dartIn the dockerfile i added ENV MAVEN_OPTS -Djava.net.preferIPv4Stack=true

RUN apt-get install apt-transport-https -y
RUN sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
RUN sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
RUN apt-get update
RUN apt-get install dart -y
ENV DART_HOME /usr/lib/dart

RUN apt-get -y install ca-certificates curl
ADD globaleda.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates
RUN git config --global http.sslverify false 
RUN apt-get update
RUN curl -sSL https://get.docker.com/ubuntu/ | sudo sh
ENV DOCKER_HOST tcp://*************
ADD .dockercfg /
RUN rm -f /app/init
ADD init /app/
RUN chmod 777 /app/init

Ci dockerfile is unmodified version of sameersbn/gitlab-ci:5.2.0.

when i compile a maven project (with mvn install) it starts to download the required artifacts and the download hangs, if i retry the download over and over again it manages to fully download problem is i need to download all at once without interruptions (it manages to continue cause im storing all the downloads on a mapped volume)

Observations:

-I deployed the Ci runner container on my local machine instead of the server and linked to the gitlab ci and the problem persists.

-If you go inside the container (with docker-enter script or docker exec container bash) and run mvn install on a terminal it downloads everything as it should, although downloading it within the build it hangs.

-i tried using Setting MAVEN_OPTS to -Djava.net.preferIPv4Stack=true on dockerfile of CI-Runner,i also tried to include it in the build script of CI-Runner to force this variable:

  • In the dockerfile i added ENV MAVEN_OPTS -Djava.net.preferIPv4Stack=true
  • In the build script i added MAVEN_OPTS=-Djava.net.preferIPv4Stack=true

-Running in debug mode (-e) or reading the logs the only information i have is :Download Timeout

Advertisement

Answer

UPDATE: Maven doesnt actually hangs, the build is completed successfully.But the runner doesnt communicate to the gitlab ci saying it made its work sucessfully due to a response error: 500.

>     2015-01-02 18:37:54 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:02 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:06 +0000 | Completed build 439, success.
>     2015-01-02 18:38:06 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:15 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:18 +0000 | Completed build 439, success.
>     2015-01-02 18:38:18 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:27 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:30 +0000 | Completed build 439, success.
>     2015-01-02 18:38:30 +0000 | Submitting build 439 to coordinator...response error: 500
>     2015-01-02 18:38:39 +0000 | Submitting build 439 to coordinator...response error: 500

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement