Why container stop after succeful registeration runner?

324 Views Asked by At

I want to register gitlab runner once in my docker-compose. yaml. I touch the command in command section to register in non interactive mode.Why container stop after succeful register runner? version: '3.6'

volumes:
  portainer_data:

networks:
  mnt_network:
    ipam:
      config:
        - subnet: 172.20.0.0/24

services:
  executor_docker_kaniko:
    container_name: ${CONTAINER_NAME_PREFIX}kaniko
    image: gitlab/gitlab-runner:alpine3.13-v14.8.3
    #restart: unless-stopped
    depends_on:
      - gitlab
    volumes:
       - ./workspace:/home/gitlab-runner
       #- ./executor_docker/config/config.json:/kaniko/.docker/config.json
       #- ./kaniko/ssl:/kaniko/ssl/certs
       #- /srv/gitlab/config/ssl:/kaniko/ssl/certs
       - /srv/gitlab/config/ssl:/etc/gitlab-runner/certs
       - /var/run/docker.sock:/var/run/docker.sock 
       - ./executor_docker/config/:/etc/gitlab-runner
    #build: 
    #  context: ./executor_docker/build/
    #  dockerfile:  Dockerfile.txt
    command: register --non-interactive --executor "docker" --docker-image gcr.io/kaniko-project/executor:debug --tls-ca-file=/etc/gitlab-runner/certs/gitlab.blk-astra-v01.crt  --url=https://gitlab.blk-astra-v01/ --registration-token=${PROJECT_REGISTRATION_TOKEN} --description "executor_docker-kaniko" --tag-list "linux"  --run-untagged="true" \
         --maintenance-note "Free-form maintainer notes about this runner" \
         --locked="false" \
         --access-level="not_protected" 
    #команда  ниже регистрирует  раннер где executor= docker, а image =kaniko
    #command:>
    # -run 
    #  - --user=gitlab-runner 
    #  - --working-directory=/home/gitlab-runner
    extra_hosts:
      - "${GITLAB_SERVER_NAME}:192.168.100.224"
      - "blk-astra-v01:192.168.100.224"

docker log: Runtime platform arch=amd64 os=linux pid=7 revision=16ae0625 version=14.8.3 Running in system-mode.

Registering runner... succeeded runner=xW84U-_X Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

1

There are 1 best solutions below

0
sytech On

The container exits because the register command exits. You probably want to use the run command, which is the default command for the image.

You only need to run the register command once, which will write the config to the /etc/gitlab-runner/ directory, which is expected to be mounted when you start the container.

So, assuming you've already successfully written the config, you should be able to just remove the command: key from your compose file and the runner should work as expected.