# Logstash container gets closed automatically after installation of the "logstash-input-mongodb" plugin

**URL:** <https://discuss.elastic.co/t/logstash-container-gets-closed-automatically-after-installation-of-the-logstash-input-mongodb-plugin/351479>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [January 20, 2024, 1:41pm UTC](https://discuss.elastic.co/t/logstash-container-gets-closed-automatically-after-installation-of-the-logstash-input-mongodb-plugin/351479 "2024-01-20T13:41:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vladyslav\_Googlya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vladyslav_googlya/32/130964_2.png) [@Vladyslav\_Googlya](https://discuss.elastic.co/u/Vladyslav_Googlya)\
**Post date:** [January 20, 2024, 1:41pm UTC](https://discuss.elastic.co/t/logstash-container-gets-closed-automatically-after-installation-of-the-logstash-input-mongodb-plugin/351479/1 "2024-01-20T13:41:55Z")

</div>

Hi everyone, I'm trying to run the Logstash container in the docker-compose file to sync my MongoDB data with Elastic. But, after the step of installation of the "logstash-input-MongoDB" plugin, the container gets exited for some reason. Any help would be appreciated.

docker-compose.yml

```auto
  logstash:
      image: docker.elastic.co/logstash/logstash:7.17.16
      container_name: logstash
      volumes:
        - ./logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
      ports:
        - '9600:9600'
      depends_on:
        - elastic
        - database
      networks:
        - appnet
      command: bin/logstash-plugin install logstash-input-mongodb && bin/logstash -f /usr/share/logstash/pipeline/logstash.conf

```

logstash.conf

```auto
input {
  mongodb {
    uri => 'mongodb://mongo_host:27017/mydatabase'
    placeholder_db_dir => '/opt/logstash-mongodb/'
    placeholder_db_name => 'logstash_sqlite_devices.db'
    collection => 'devices'
    batch_size => 5000
  }

  mongodb {
    uri => 'mongodb://mongo_host:27017/mydatabase'
    placeholder_db_dir => '/opt/logstash-mongodb/'
    placeholder_db_name => 'logstash_sqlite_vendors.db'
    collection => 'vendors'
    batch_size => 5000
  }
}

filter {
  mutate {
    remove_field => ["_id"]
  }
}

output {
  elasticsearch {
    hosts => ['elastic:9200']
    index => "%{[@metadata][index]}"
  }
}

```

 ![2024-01-20_15-41](https://us1.discourse-cdn.com/elastic/original/3X/0/d/0d2b57392cef45c844db1db2312fe7ff0353f2dc.png)

---

<div class="post-metadata">

**Author:** ![strawgate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/strawgate/32/131008_2.png) [@strawgate](https://discuss.elastic.co/u/strawgate)\
**Post date:** [January 23, 2024, 12:16am UTC](https://discuss.elastic.co/t/logstash-container-gets-closed-automatically-after-installation-of-the-logstash-input-mongodb-plugin/351479/2 "2024-01-23T00:16:14Z")

</div>

`&&` is a function provided by a shell. Can you try something like: `command: bash -c "bin/logstash-plugin install logstash-input-mongodb && bin/logstash -f /usr/share/logstash/pipeline/logstash.conf logstash.conf"`

Note: I have not tested this command and I have written it freehand

---

<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:** [February 20, 2024, 12:16am UTC](https://discuss.elastic.co/t/logstash-container-gets-closed-automatically-after-installation-of-the-logstash-input-mongodb-plugin/351479/3 "2024-02-20T00:16:47Z")

</div>

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