Running Kibana in Docker image gives Non-Root error

Viewed 2384

I'm having issues attempting to setup the ELK stack (v7.6.0) in docker using Docker-Compose.

Elastic Search & Logstash startup fine, but Kibana instantly exists, the docker logs for that container report:

Kibana should not be run as root.  Use --allow-root to continue.

the docker-compose for those elements looks like this:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
    mem_limit: 2gb

  kibana:
    image: docker.elastic.co/kibana/kibana:7.6.0
    environment:
      - discovery.type=single-node
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

  logstash:
    image: docker.elastic.co/logstash/logstash:7.6.0
    ports:
      - "5000:5000/tcp"
      - "5000:5000/udp"
      - "9600:9600"
    mem_limit: 2gb
    depends_on:
      - elasticsearch

How do I either disable the run as root error, or set the application to not run as root?

3 Answers

In case you don't have a separate Dockerfile for Kibana and you just want to set the startup arg in docker-compose, the syntax there is as follows:

kibana:
    container_name: kibana
    image: docker.elastic.co/kibana/kibana:7.9.2
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
    environment:
      - ELASTICSEARCH_URL=http://localhost:9200
    networks:
      - elastic
    entrypoint: ["./bin/kibana", "--allow-root"] 

That works around the problem of running it on a Windows Container.
That being said, I don't know why Kibana should not be executed as root.

i've just run this docker image and all works perfectly, i share my docker-compose file:

version: '3.7'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
    container_name: elasticsearch
    environment:
       - node.name=node
       - cluster.name=elasticsearch-default
       - bootstrap.memory_lock=true
       - discovery.type=single-node
       - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    ports:
      - "9200:9200"
    expose: 
      - "9200"
    networks:
      - "esnet"

  kibana:
    image: docker.elastic.co/kibana/kibana:7.6.0
    container_name: kibana
    ports:
      - "5601:5601"
    expose: 
      - "5601"
    networks:
      - "esnet"
    depends_on: 
      - elasticsearch

 logstash:
   image: docker.elastic.co/logstash/logstash:7.6.0
   ports:
     - "5000:5000/tcp"
     - "5000:5000/udp"
     - "9600:9600
   depends_on: 
     - elasticsearch
   networks:
     - "esnet"
networks: 
  esnet:

I had the same problem. I did run it manually by adding the ENTRYPOINT to the end of Dockerfile.

ARG ELK_VERSION  
FROM docker.elastic.co/kibana/kibana:${ELK_VERSION}
ENTRYPOINT ["./bin/kibana", "--allow-root"]

The docker-compose.yml

version: '3.2'
# Elastic stack (ELK) on Docker https://github.com/deviantony/docker-elk
services:
  elasticsearch:
    build:
      context: elasticsearch/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: volume
        source: elasticsearch
        target: /usr/share/elasticsearch/data
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
      ELASTIC_PASSWORD: changeme
      discovery.type: single-node
    networks:
      - elk

  logstash:
    build:
      context: logstash/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: bind
        source: ./logstash/pipeline
        target: /usr/share/logstash/pipeline
        read_only: true
    ports:
      - "5002:5002/tcp"
      - "5002:5002/udp"
      - "9600:9600"
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    networks:
      - elk
    depends_on:
      - elasticsearch

  kibana:
    build:
      context: kibana/ ##############  Dockerfile ##############
      args:
        ELK_VERSION: $ELK_VERSION
    ports:
      - "5601:5601"
    networks:
      - elk
    depends_on:
      - elasticsearch

networks:
  elk:
    driver: nat

volumes:
  elasticsearch:
Related