Py学习  »  docker

远程服务器上的Docker上下文来自守护程序的错误响应:无效的卷规范

jay5on • 3 年前 • 1027 次点击  

我正在使用docker上下文将本地容器部署到debian Web服务器。我在Windows 10上使用Docker Desktop for Windows。应用程序是用Flask编写的。

在某个时候,我尝试了“docker compose up--build--after--docker context use remote”-

来自守护程序的错误响应:无效的卷规范:C:\Users\user\fin:/fin:rw–of

在本地,当我尝试将其部署到生产服务器时,会弹出错误。

Dockerfile如下所示:

FROM python:3.8-slim-buster

ENV INSTALL_PATH /app
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH

ENV PATH="/home/user/.local/bin:${PATH}"

COPY . ./

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN useradd -ms /bin/bash user && chown -R user $INSTALL_PATH
USER user

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

RUN pip install --upgrade pip

CMD gunicorn -c "python:config.gunicorn" "fin.app:create_app()"

而docker的一段摘录。yml如下所示:

version: '3.8'

services:
  flask-app:
    container_name: flask-app
    restart: always
    build: .
    command: >
      gunicorn -c "python:config.gunicorn" "fin.app:create_app()"
    environment:
      PYTHONUNBUFFERED: 'true'
    volumes:
      - '.:/fin'
    ports:
      - 8000:8000
    env_file:
      - '.env'

在教室里。env file选项 已设置“合成”\u“转换”\u“窗口”\u路径=1。

在某个时刻,我在安装了Ubuntu的情况下使用WSL2尝试了相同的过程,结果显示了以下消息:

Error response from daemon: create \\wsl.localhost\Ubuntu-20.04\home\user\fin: "\\\\wsl.localhost\\Ubuntu-20.04\\home\\user\\fin" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path

基于此消息,我将Dockerfile更改为:

FROM python:3.8-slim-buster

ENV INSTALL_PATH=/usr/src/app
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH

ENV PATH=/home/user/.local/bin:${PATH}

COPY . /usr/src/app/

# set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
#ENV COMPOSE_CONVERT_WINDOWS_PATHS=1

RUN useradd -ms /bin/bash user && chown -R user $INSTALL_PATH
USER user

COPY requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt

RUN pip install --upgrade pip

CMD gunicorn -c "python:config.gunicorn" "fin.app:create_app()"

但错误仍然存在,我必须知道如何解决它。

提前感谢您的帮助。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/133288
 
1027 次点击  
文章 [ 2 ]  |  最新文章 3 年前