# Not able to run the script to create dashboard in docker kibana

**URL:** <https://discuss.elastic.co/t/not-able-to-run-the-script-to-create-dashboard-in-docker-kibana/138999>\
**Category:** Kibana\
**Created:** [July 7, 2018, 5:13am UTC](https://discuss.elastic.co/t/not-able-to-run-the-script-to-create-dashboard-in-docker-kibana/138999 "2018-07-07T05:13:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikrant\_Aggarwal](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@Vikrant\_Aggarwal](https://discuss.elastic.co/u/Vikrant_Aggarwal)\
**Post date:** [July 7, 2018, 5:13am UTC](https://discuss.elastic.co/t/not-able-to-run-the-script-to-create-dashboard-in-docker-kibana/138999/1 "2018-07-07T05:13:15Z")

</div>

I am using the following compose file. My objective is to create the kibana dashboard automatically when the docker container starts hence I created customize image for kibana.

```auto
version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    container_name: elasticsearch
    environment:
      - "discovery.type=single-node"
      - "xpack.security.enabled=false"
      - "xpack.monitoring.enabled=false"
    volumes:
      - esdata:/usr/share/elasticsearch/data:rw
    ports:
      - 9200:9200
    networks:
      - elk
    restart: unless-stopped
  kibana:
    depends_on:
    - elasticsearch
    #image: docker.elastic.co/kibana/kibana:6.2.4
    image: ervikrant06/kibana:6.2.4.v1
    environment:
      - "xpack.monitoring.enabled=false"
    networks:
      - elk
    ports:
      - 5601:5601
    restart: unless-stopped
    command: sh bp-dashboard.sh
  logstash:
    image: ervikrant06:logstashv3
    #image: docker.elastic.co/logstash/logstash:6.2.4
    depends_on:
      - elasticsearch
    networks:
      - elk
    environment:
      - "xpack.security.enabled=false"
      - "INPUT1=/var/tmp/log"
      - "xpack.monitoring.enabled=false"
    restart: unless-stopped
    #volumes:
      #- /tmp/logstash/:/var/tmp/log
      #- /root/elk-logparser/pipeline/:/usr/share/logstash/pipeline/
volumes:
  esdata:
    driver: local
networks:
  elk:

```

Following is the dockerfile used to create kibana image:

```auto
# cat kibana/Dockerfile
FROM docker.elastic.co/kibana/kibana:6.2.4
ADD . /usr/share/kibana

```

content of the script which is used to issue curl POST command.

```auto
# cat bp-dashboard.sh
#!/bin/bash
sleep 30
curl -XPOST kibana:5601/api/kibana/dashboards/import -H 'kbn-xsrf:true' -H 'Content-type:application/json' -d @/usr/share/kibana/bp-dashboard.json

```

I have already verified that after running the container using docker run command I am able to run the script inside the container without any issue.

This is what i have seen on the screen after running docker-compose up.

```auto
kibana_1 | % Total % Received % Xferd Average Speed Time Time Time Current
kibana_1 | Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed connect to kibana:5601; Connection refused
kibana_1 | % Total % Received % Xferd Average Speed Time Time Time Current
kibana_1 | Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed connect to kibana:5601; Connection refused
kibana_1 | % Total % Received % Xferd Average Speed Time Time Time Current
kibana_1 | Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed connect to kibana:5601; Connection refused

```

Anyone can please help me to point what I am doing wrong here?

---

<div class="post-metadata">

**Author:** ![Johnnycc1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johnnycc1/32/26069_2.png) [@Johnnycc1](https://discuss.elastic.co/u/Johnnycc1)\
**Post date:** [July 7, 2018, 11:24pm UTC](https://discuss.elastic.co/t/not-able-to-run-the-script-to-create-dashboard-in-docker-kibana/138999/2 "2018-07-07T23:24:58Z")

</div>

I think the recommended approach is to have a short lived container outside Kibana for this.

See this example [https://github.com/swarmee/projects/tree/master/elastic-stack-6.3](https://github.com/swarmee/projects/tree/master/elastic-stack-6.3)

---

<div class="post-metadata">

**Author:** ![Vikrant\_Aggarwal](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@Vikrant\_Aggarwal](https://discuss.elastic.co/u/Vikrant_Aggarwal)\
**Post date:** [July 9, 2018, 2:30am UTC](https://discuss.elastic.co/t/not-able-to-run-the-script-to-create-dashboard-in-docker-kibana/138999/3 "2018-07-09T02:30:23Z")

</div>

Many thanks John for your comment.

I tried your suggestion and modified my docker-swarm file referring your one.

Despite of adding the dependency still it's trying to start the sidecar container first and later on kibana and es.

```auto
# docker-compose up
Creating network "elk-logparser_elk" with the default driver
Creating volume "elk-logparser_esdata" with local driver
Creating elasticsearch ... done
Creating logstash ... done
Creating kibana ... done
Creating load-sample-data ... done
Attaching to elasticsearch, logstash, kibana, load-sample-data
logstash | 2018/07/09 02:25:56 Setting 'xpack.monitoring.enabled' from environment.
logstash | OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
load-sample-data | % Total % Received % Xferd Average Speed Time Time Time Current
load-sample-data | Dload Upload Total Spent Left Speed
  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to kibana port 5601: Connection refused
load-sample-data exited with code 7

```

Here is my modified docker-compose.yml file.

```auto
version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    container_name: elasticsearch
    environment:
      - "discovery.type=single-node"
      - "xpack.security.enabled=false"
      - "xpack.monitoring.enabled=false"
    volumes:
      - esdata:/usr/share/elasticsearch/data:rw
    ports:
      - 9200:9200
    networks:
      - elk
    restart: unless-stopped
  kibana:
    container_name: kibana
    depends_on:
    - elasticsearch
    image: docker.elastic.co/kibana/kibana:6.2.4
    environment:
      - "xpack.monitoring.enabled=false"
    networks:
      - elk
    ports:
      - 5601:5601
    restart: unless-stopped
  logstash:
    image: ervikrant06:logstashv3
    container_name: logstash
    #image: docker.elastic.co/logstash/logstash:6.2.4
    depends_on:
      - elasticsearch
    networks:
      - elk
    environment:
      - "xpack.security.enabled=false"
      - "INPUT1=/var/tmp/log"
      - "xpack.monitoring.enabled=false"
    restart: unless-stopped
    #volumes:
      #- /tmp/logstash/:/var/tmp/log
      #- /root/elk-logparser/pipeline/:/usr/share/logstash/pipeline/
  configure_stack:
    depends_on:
      - kibana
    container_name: load-sample-data
    #build: ./load-sample-data
    image: elk-logparser_configure_stack
    command: ['/bin/bash', '-c', 'cat /tmp/sample/bp-dashboard.sh | tr -d "\r" | bash']
    networks:
      - elk
volumes:
  esdata:
    driver: local
networks:
  elk:

```

i am not able to understand why it's not honoring the depends\_on condition mentioned in compose. If it then I believe everything will work fine.

```auto

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 6, 2018, 2:30am UTC](https://discuss.elastic.co/t/not-able-to-run-the-script-to-create-dashboard-in-docker-kibana/138999/4 "2018-08-06T02:30:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
