提问人:Ivan Barbosa Pinheiro 提问时间:11/17/2023 更新时间:11/17/2023 访问量:22
Docker 中的卷问题:docker-compose 中的 Jupyter 和 Postgres
Volume issues in Docker: Jupyter and Postgres in docker-compose
问:
我正在通过 Docker Compose 使用 Jupyter 和 Postgres。但是,在创建容器时,映射到容器目录 /home/jovyan/work 的主机卷不可用于访问。我尝试遵循此链接上提供的官方文档中的一些建议,但我没有成功。我需要进行哪些修改才能使“work”文件夹可供默认用户“jovyan”使用?如果可以通过其他方法提供该目录,那也将不胜感激!
yml 文件
version: '3.7'
services:
postgres:
image: postgres:latest
container_name: postgres-db1
environment:
POSTGRES_DB: FapCov2103
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- "H:\\docs\\www\\public\\SCC0244\\data:/home/jovyan/work"
ports:
- "5432:5432"
restart: unless-stopped
networks:
- mynetwork
nobel:
image: postgres:latest
container_name: postgres-db2
environment:
POSTGRES_DB: Nobel
POSTGRES_USER: postgres2
POSTGRES_PASSWORD: postgres2
volumes:
- "H:\\docs\\www\\public\\SCC0244\\data:/home/jovyan/work"
ports:
- "5433:5432"
restart: unless-stopped
networks:
- mynetwork
jupyter:
build:
context: .
dockerfile: Dockerfile # Usando o Dockerfile personalizado
ports:
- "8888:8888"
volumes:
- "C:\\Users\\ivanp\\OneDrive\\Área de Trabalho\\scc0244:/home/jovyan/work"
networks:
- mynetwork
depends_on:
- postgres
container_name: jupyter-datascience
networks:
mynetwork:
Docker文件
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG REGISTRY=quay.io
ARG OWNER=jupyter
ARG BASE_CONTAINER=$REGISTRY/$OWNER/base-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <[email protected]>"
# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
USER root
# Defina variáveis de ambiente no Dockerfile
ENV GRANT_SUDO="yes"
COPY ./requirements.txt /tmp/requirements.txt
# Install all OS dependencies for fully functional Server
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
# Common useful utilities
curl \
git \
nano-tiny \
tzdata \
unzip \
vim-tiny \
# git-over-ssh
openssh-client \
# less is needed to run help in R
# see: https://github.com/jupyter/docker-stacks/issues/1588
less \
# nbconvert dependencies
# https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex
texlive-xetex \
texlive-fonts-recommended \
texlive-plain-generic \
# Enable clipboard on Linux host systems
xclip && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
pip install -r /tmp/requirements.txt
# Create alternative for nano -> nano-tiny
RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10
# Switch back to jovyan to avoid accidental container runs as root
USER ${NB_UID}
我尝试遵循此链接上提供的官方文档中的一些建议
答: 暂无答案
评论