entrypoint.sh:Windows 10上没有此类文件或目录

时间:2020-06-26 11:48:34

标签: docker docker-compose dockerfile

我有Django项目,正在使用docker-compose进行设置。我浏览了各种博客以及关于stackoverflow的问题,所有这些都指出了入口点文件和文件类型的权限问题。我修复了它,它在Linux上有效。但它在Windows 10上不起作用,并失败,并显示以下错误

ERROR: for web  Cannot start service web: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"./entrypoint.sh\": stat ./entrypoint.sh: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.

以下是我的docker文件

FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
COPY entrypoint.sh /code/
RUN chmod +x entrypoint.sh
RUN pip install -r requirements.txt
COPY . /code/

Docker-compose文件

version: '3'

services:
  web:
    build: .
    entrypoint: ./entrypoint.sh
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    networks:
      - backend
    depends_on:
      - db
    environment:
      wait_hosts: db:5434
      POSTGRES_DB: ${POSTGRES_DATABASE}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
      DJANGO_SECRET_KEY: ${DJANGO_SECRET_KEY}
  
  db:
    image: postgres
    environment:
      POSTGRES_DB: ${POSTGRES_DATABASE}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_USER: ${POSTGRES_USER}
    networks:
      - backend
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    ports:
      - "5434:5432"

入口点文件

#!/bin/sh

# Collect static files
echo "Collect static files"
python manage.py collectstatic --noinput

# Create database migrations
echo "Creating database migrations"
python manage.py makemigrations

# Apply database migrations
echo "Apply database migrations"
python manage.py migrate

# Start server
echo "Starting server"
python manage.py runserver 0.0.0.0:8000

1 个答案:

答案 0 :(得分:0)

弄清楚了。我正在使用Windows 10 Home和Docker工具箱。默认情况下,必须将代码放置在C /用户中。如果要使用其他目录,则必须在虚拟框共享文件夹中添加路径。