Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unknown shorthand flag: 'd' in -d docker compose

I am working with a docker compose. when a trying to run docker compose in background, but it shows error unknown shorthand flag: 'd' in -d

I am tried in this way

docker compose -d up

docker-compose.yml

version: '3'

networks:
  loki:

services:
  loki:
    image: grafana/loki:2.5.0
    # volumes:
    #   - ./loki:/loki
    ports:
      - 3100:3100
    networks:
      - loki
  
  promtail:
    image: grafana/promtail
    volumes:
      - ./promtail:/etc/promtail
      - /var/log/nginx/:/var/log/nginx/
    command: -config.file=/etc/promtail/promtail-config.yml
    ports:
      - 9080:9080
    networks:
      - loki
  
  grafana:
    image: grafana/grafana
    ports:
      - 3000:3000
    networks:
      - loki
    
  
like image 327
Amjed saleel Avatar asked Nov 30 '25 14:11

Amjed saleel


1 Answers

The accepted answer is the right answer for the question asker and anyone else putting the -d in the wrong place. But this is the top hit for the error message, and I'm sure I'm not the only one getting this error after running:

docker-compose up -d

The accepted answer telling me to run exactly what I ran was pretty confusing. I finally worked out that:

  1. docker-compose is a separate package from docker, at least on Arch Linux, and likely elsewhere, and

  2. If docker-compose isn't installed, Docker thinks this makes sense:

    $ docker compose up -d
    unknown shorthand flag: 'd' in -d
    

I think it would be infinitely more sensible to respond with:

docker: 'compose' is not a docker command.

That is what it says if you don't use -d while not having docker-compose installed, and my view is that adding -d shouldn't change that.

I've now installed docker-compose and things are working, but I thought it was worth the time to hopefully save someone else some trouble if they end up here because they have docker but not docker-compose.

like image 103
Darshan Rivka Whittle Avatar answered Dec 09 '25 00:12

Darshan Rivka Whittle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!