我正在使用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/