How to mention (docker run) flags in docker-compose file

I created a image for elasticsearch & running the image as

docker run -it -v elasticsearch_data:/usr/src/elastic/elasticsearch-2.3.4/data -v elasticsearch_logs:/usr/src/elastic/elasticsearch-2.3.4/logs -p 9200:9200 -p 9300:9300 --net=host --memory="4g" -e ES_HEAP_SIZE=2g telednacomm/elastic

Its working fine. But I want to run this image through docker-compose. For that

version: '2' services: node: image: telednacomm/nodepm2 ports: - "3000:3000" elastic: image: telednacomm/elastic volumes: - elasticsearch_data:/usr/src/elastic/elasticsearch-2.3.4/data - elasticsearch_logs:/usr/src/elastic/elasticsearch-2.3.4/logs ports: - "9200:9200" - "9300:9300"

I written like this. But how to mention --net=host and --memory="4g" these flags inside the compose file. Or any other way to do this???

1 Like

–memory=“4g” is doable in compose:

  resources:
    # max amount of memory Docker will allocate     
    limits:
      cpus: '0.5'
      memory: 1024M
    # desired amount of memory Docker will try to use          
    reservations:
      cpus: '0.25'
      memory: 512M

however me too would like to know if there is a way how to do --privileged --net host --pid host with compose file and docker stack deploy combination.