pilec
pilec

Reputation: 513

Elasticsearch service does't start on gitlab - docker container already in use

I have my own CI server with gitlab and I'm trying to run docker runner (version 10.6) with this configuration:

image: php:7.1

services:
  - mysql:latest
  - redis:latest
  - elasticsearch:latest

before_script:
  - bash ci/install.sh > /dev/null
  - php composer install -a

stages:
  - test

test:
  stage: test
  variables:
    API_ENVIRONMENT: 'test'
  script:
  - echo "Running tests"
  - php composer app:tests

But everytime when I pull docker container with elastic, I've got error message:

*** WARNING: Service runner-1de473ae-project-225-concurrent-0-elasticsearch-2 probably didn't start properly.

Error response from daemon: Conflict. The container name "/runner-1de473ae-project-225-concurrent-0-elasticsearch-2-wait-for-service" is already in use by container "f26f56b2905e8c3da1977bc7c48e7eba00e943532146b7a8711f91fe67b67c3b". You have to remove (or rename) that container to be able to reuse that name.

*********

I also tried to log into this server and list all containers, but there is only redis one:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
5cec961e03b2        811c03fb36bc        "gitlab-runner-ser..."   39 hours ago        Up 39 hours                             runner-1de473ae-project-247-concurrent-1-redis-1-wait-for-service

After googling this problem I found this issue: https://gitlab.com/gitlab-org/gitlab-runner/issues/2667 then I update runner to 10.6, but problem persists.

After all, there is no running elastic on my server, then my tests fails on:

FAILED: Battle/BattleDataElasticProviderTest.php method=testGetLocalBattles
   Exited with error code 255 (expected 0)
   Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster

Is there any way, how to start ES or at least put ES into more verbosive mode?

Thanks!

Upvotes: 1

Views: 1808

Answers (1)

Yuankun
Yuankun

Reputation: 7793

When a container is stopped, it still exists even though it's now in an exited state. Using command docker ps -a shows you all the running and exited containers.

To start a new container with an already existing name, you need to first manually remove the old container occupying this name by using docker rm.

A convenient way is to use the --rm argument when starting a container, the container will be automatically removed once it stops.

Upvotes: 3

Related Questions