Tag Archives: yml

Docker compose executes the YML file error [How to Solve]

ERROR: Couldn’t connect to Docker daemon at http+ docker://localhost – is it running?

$sudo docker compose up. To start with sudo, enter the password

Other explanations (used, no)

Answer: the main reason is that docker is not started in the system service mode.

Solution:

  1. Start docker servic
  2. Generate self-starting services
  3. Check the service status, Active status is: active (running)

【docker】 yaml.scanner.ScannerError: mapping values are not allowed here in “./docker-compo…

An error was reported when starting docker compose

Command:

docker-compose up -d && docker-compose logs -f

Error code:

Solution

The reason for this error is that the YML format is incorrect. The YML format defined by Google is too strict. Every colon must be followed by a space

Original format:

version:"3"
services:
  web:   
    image: licerlee/friendlyhello:v1
    deploy:
      replicas:5
      resources:
        limits:
          cpus:"0.1"
          memory:50M
      restart_policy:
        condition: on-failure
    ports:
      - "80:80"
    networks:
      - webnet
networks:
  webnet:

Change to:

version: "3"
services:
  web:
   
    image: licerlee/friendlyhello:v1
    deploy:
      replicas: 5
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
      restart_policy:
        condition: on-failure
    ports:
      - "80:80"
    networks:
      - webnet
networks:
  webnet:

Note: the above example is for illustration only, not the configuration file of my project

When executing the command:

It’s over!