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

Viewed 2195

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
    
  
2 Answers

-d is an option of subcommand up. if you run docker compose up --help you will have more information.

To solve the problem run docker compose up -d

We were using a legacy version of Docker for compatibility purposes; in the older versions it's docker-compose not docker compose. Changing it to be hyphenated resolved this error.

Related