首页 > 解决方案 > sh:1:混合:未找到-Docker-Compose

问题描述

尝试在 docker 中启动 npm 容器时,我不断遇到以下问题,我似乎无法弄清楚发生了什么。它不断尝试启动 npm,然后退出并且不运行。

在此处输入图像描述

  | sh: 1: mix: not found
    npm-aws         | npm ERR! code ELIFECYCLE
    npm-aws         | npm ERR! syscall spawn
    npm-aws         | npm ERR! file sh
    npm-aws         | npm ERR! errno ENOENT
    npm-aws         | npm ERR! @ watch-poll: `mix watch -- --watch-options-poll=3000`
    npm-aws         | npm ERR! spawn ENOENT
    npm-aws         | npm ERR!
    npm-aws         | npm ERR! Failed at the @ watch-poll script.
    npm-aws         | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm-aws         | 
    npm-aws         | npm ERR! A complete log of this run can be found in:
    npm-aws         | npm ERR!     /root/.npm/_logs/2021-10-05T22_43_50_263Z-debug.log

码头工人-compose.yml:

version: '3'

networks:
  laravel:

services:
  testing-aws:
    build:
      context: .
      dockerfile: nginx.dockerfile
    container_name: nginx-aws
    ports:
      - 5001:5001
    volumes:
      - ./src:/var/www/html:delegated
    depends_on:
      - php
      - mysql
    links:
      - mysql
    networks:
      - laravel

  mysql:
    image: mysql:5.6
    container_name: mysql-aws
    restart: unless-stopped
    tty: true
    ports:
      - 3306:3306
    environment:
      MYSQL_HOST: mysql
      MYSQL_DATABASE: heatable
      MYSQL_USER: heatable
      MYSQL_ROOT_PASSWORD: password
    networks:
      - laravel
    volumes:
      - ./mysql:/var/lib/mysql

  php:
    build:
      context: .
      dockerfile: php.dockerfile
    container_name: php-aws
    volumes:
      - ./src:/var/www/html:delegated
    networks:
      - laravel
    links:
      - mysql
    depends_on:
      - mysql

  composer:
    build:
      context: .
      dockerfile: composer.dockerfile
    container_name: composer-aws
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - php
    user: laravel
    entrypoint: ['composer', '--ignore-platform-reqs']
    networks:
      - laravel

  npm:
    build:
      context: .
      dockerfile: npm.dockerfile
    container_name: npm-aws
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    command: npm run watch-poll
    networks:
      - laravel
    
  artisan:
    build:
      context: .
      dockerfile: php.dockerfile
    container_name: artisan-aws
    volumes:
      - ./src:/var/www/html:delegated
    depends_on:
      - mysql
    working_dir: /var/www/html
    user: laravel
    entrypoint: ['php', '/var/www/html/artisan']
    links:
      - mysql
    networks:
      - laravel

npm.docker 文件:

FROM node:14.17.1
WORKDIR /var/www/html
COPY ./src/package.json .
RUN npm install
RUN npm clean-install
CMD npm run watch-poll

更新

我设法通过添加来解决它tty: true,请参阅更新:

  npm:
    tty: true
    build:
      context: .
      dockerfile: npm.dockerfile
    container_name: npm-aws
    working_dir: /var/www/html
    networks:
      - laravel

npm install如果有人知道没有手动输入命令的修复方法,我必须在容器的终端中手动运行才能获取节点模块。请告诉我 :)

标签: dockerdocker-composedockerfilelaravel-mixdocker-container

解决方案


推荐阅读