windows - Docker在Linux环境而不是Windows环境下撰写工作

标签 windows docker docker-compose dockerfile

我正在使用2种环境进行开发,一种是在家中使用Linux VM,另一种是办公室中使用Windows笔记本电脑。 Angular 环境的dockerfile可以正常工作直到几天前,当我尝试在笔记本电脑上使用docker compose启动docker容器时,它显示以下错误:

ng    | /bin/sh: 1: sudo: not found
ng exited with code 127

但是,在我的Linux VM上不会发生相同的问题。

Dockerfile:
FROM node:12

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable

RUN mkdir /app
WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY package.json package-lock.json /app/

RUN npm install
#RUN npm install -g @angular/cli

COPY . /app

EXPOSE 4200

CMD ng serve --host 0.0.0.0

docker-compose.yaml:
version: "3"

services:
  dj:
    container_name: dj
    build: Backend
    command: python manage.py runserver 0.0.0.0:80
    volumes:
      - ./Backend:/code
    ports:
      - "80:80"
  ng:
    container_name: ng
    build: Frontend/SPort
    volumes:
      - ./Frontend/SPort:/app
    ports:
      - "4200:4200"

最佳答案

我认为您想在sh中修复Dockerfile脚本

添加以下内容:

RUN  apt-get update && apt-get install -y dos2unix && dos2unix /path/to/the/script

希望会有所帮助,因为错误来自Windows中的CRLF字符

关于windows - Docker在Linux环境而不是Windows环境下撰写工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56967362/

相关文章:

mongodb - mongod --bind_ip 使用 docker-compose 版本 2

windows - EnumDesktops 命名的所有桌面都无法打开桌面,错误为 2 "File not found"

windows - Node.JS NPM 无法在 Windows 上运行

docker - 有没有办法通过远程桌面连接到正在运行的 Windows Server 容器?

linux - Letsencrypt + Docker - 处理符号链接(symbolic link)的最佳方式?

docker - 如何删除 nginx docker 容器中的服务器 header ?

python - python "failed to create process"

windows - 拖动控制面板项时从 CIDA 获得错误的 PIDL

php - 如何使用 php-fpm 和 php-cli 运行 docker-compose?

docker - 在 docker 容器之间连接到 scality/s3 服务器