社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  docker

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

jay5on • 3 年前 • 939 次点击  

我正在使用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
 
939 次点击  
文章 [ 2 ]  |  最新文章 3 年前
flaxon
Reply   •   1 楼
flaxon    3 年前

使用此选项(不带引号,并带有斜线,这样它就知道你指的是这个文件夹):

volumes:
    - ./:/fin
LiquidDeath
Reply   •   2 楼
LiquidDeath    3 年前

您得到的卷规格无效: C:\Users\user\fin:/fin:rw 在您的生产环境中是因为,主机路径 C:\Users\user\fin 没有。您可以在部署时删除它,或将其更改为生产环境中可用的绝对路径,如下所示。

volumes:
    - '/root:/fin:rw'

其中/root是我的生产环境中可用的目录。

 /path:/path/in/container mounts the host directory, /path at the /path/in/container

 path:/path/in/container creates a volume named path with no relationship to the host.

注意开头的斜线。如果 / 如果存在,它将被视为主机目录,否则它将被视为卷