Docker развертывание стека: ответ об ошибке от демона: rp c ошибка: код = InvalidArgument des c = ContainerSpe c: должна быть указана ссылка на изображение - PullRequest
0 голосов
/ 08 апреля 2020

Я пытаюсь развернуть приложение со стеком docker. После сборки и тестирования с помощью docker -compose (которые запустили совершенно нормально ), я создал рой, присоединился к нему и попытался запустить

docker stack deploy --compose-file docker-compose.yml default

Произошла следующая ошибка:

failed to create service default_sharkcop-api: Error response from daemon: rpc error: code = InvalidArgument desc = ContainerSpec: image reference must be provided

Вот мой docker -compose.yml

version: "3"
services:
  # Define the api web application
  sharkcop-api:
    # Build the Dockerfile that is in the web directory
    build: 
      context: ./sharkcop-api
      dockerfile: Dockerfile
    # Always restart the container regardless of the exit status; try and restart the container indefinitely
    restart: always

    # Expose port 8000 to other containers (not to the host of the machine)
    expose:
      - "8080"

    # Link the containers together so they can talk to one another
    links:
      - redis

    # Pass environment variables to the flask container (this debug level lets you see more useful information)
    environment:
      port: 8080
      REDIS_URL: redis://cache

    # Deploy with three replicas in the case one of the containers fails (only in Docker Swarm)
    deploy:
      mode: replicated
      replicas: 3

  # Define the NGINX forward proxy container
  nginx:
    # build the nginx Dockerfile
    build: 
      context: ./reverse-proxy
      dockerfile: Dockerfile

    restart: always

    # Expose port 80 to the host machine
    ports:
      - "80:80"
    deploy:
      mode: replicated
      replicas: 3

    # The application needs to be available for NGINX to make successful proxy requests
    depends_on:
      - sharkcop-api

  # Define the sharkcop-webinspector
  sharkcop-webinspector:
    build: 
      context: ./sharkcop-webinspector
      dockerfile: Dockerfile
    restart: always

    expose:
      - "8080"

    # Mount the web directory within the container at /app/sharkcop-webinspector
    volumes:
      - ./sharkcop-webinspector:/app/sharkcop-webinspector

    links:
      - sharkcop-api

    deploy:
      mode: replicated
      replicas: 3

  redis:
    image: redis
    container_name: cache
    command: ["redis-server", "--appendonly", "yes"]
    restart: always
    expose:
      - 6379
    volumes:
      - ./data/redis:/data

Я использую Docker версия 19.03.8, сборка afacb8b и docker - составить версию 1.25.4, сборка 8d51620a

1 Ответ

1 голос
/ 08 апреля 2020

Когда вы запускаете docker stack deploy из файла композиции. Вам также необходимо упомянуть имя image при создании его из Dockerfile.

Пожалуйста, обратитесь к ниже docker -compose.yaml

version: "3"
services:
  # Define the api web application
  sharkcop-api:
    # Build the Dockerfile that is in the web directory
    image: sharcop-api
    build:
      context: ./sharkcop-api
      dockerfile: Dockerfile
    # Always restart the container regardless of the exit status; try and restart the container indefinitely
    restart: always

    # Expose port 8000 to other containers (not to the host of the machine)
    expose:
      - "8080"

    # Link the containers together so they can talk to one another
    links:
      - redis

    # Pass environment variables to the flask container (this debug level lets you see more useful information)
    environment:
      port: 8080
      REDIS_URL: redis://cache

    # Deploy with three replicas in the case one of the containers fails (only in Docker Swarm)
    deploy:
      mode: replicated
      replicas: 3

  # Define the NGINX forward proxy container
  nginx:
    # build the nginx Dockerfile
    image: nginx-proxy
    build: 
      context: ./reverse-proxy
      dockerfile: Dockerfile

    restart: always

    # Expose port 80 to the host machine
    ports:
      - "80:80"
    deploy:
      mode: replicated
      replicas: 3

    # The application needs to be available for NGINX to make successful proxy requests
    depends_on:
      - sharkcop-api

  # Define the sharkcop-webinspector
  sharkcop-webinspector:
    build: 
      context: ./sharkcop-webinspector
      dockerfile: Dockerfile
    restart: always

    expose:
      - "8080"

    # Mount the web directory within the container at /app/sharkcop-webinspector
    volumes:
      - ./sharkcop-webinspector:/app/sharkcop-webinspector

    links:
      - sharkcop-api

    deploy:
      mode: replicated
      replicas: 3

  redis:
    image: redis
    container_name: cache
    command: ["redis-server", "--appendonly", "yes"]
    restart: always
    expose:
      - 6379
    volumes:
      - ./data/redis:/data

...