gpt4 book ai didi

docker - Docker COPY成功,但经检查无文件

转载 作者:行者123 更新时间:2023-12-02 19:24:05 26 4
gpt4 key购买 nike

我将这一行放在我的Docker文件中。

COPY gorpyter_tutorial.ipynb /usr/local/man

此消息显示在 build上。
Step 4/10 : COPY gorpyter_tutorial.ipynb /usr/local/man
---> b4b53dc0c6b1

但是,当我将 exec... /bin/bash放入容器时,它不在期望目录或任何其他目录中。

$ cd ~
$ find * gorpyter_tutorial.ipynb

'find: ‘gorpyter_tutorial.ipynb’: No such file or directory'

我的其他更改,例如设置环境变量和安装库,都可以成功运行。

Dockerfile
FROM jupyter/datascience-notebook:latest

MAINTAINER layne sadler <lsadler@wuxinextcode.com>

USER root

COPY gorpyter_tutorial.ipynb /usr/local/man

RUN sudo apt-get update && sudo apt-get install openjdk-8-jdk -y

ENV JUPYTER_ENABLE_LAB=yes
ENV NOTEBOOK_DIR=/usr/local/man
ENV R_HOME=/opt/conda/lib/R
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

WORKDIR /usr/local/man

# https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s09.html

docker-compose.yml
version: "3"
services:
jupyter:
image: "hashrocketsyntax/gorpyter:skyline"
ports:
- "8888:8888"
volumes:
- /Users/laynesadler/Desktop/notebooks:/usr/local/man

因为是卷,我不允许复制到 /usr/local/man吗?

最佳答案

您的Dockerfile包含创建镜像的说明。构建镜像后,镜像可以作为容器运行。
启动容器时将附加一个卷。
因此,在构建镜像时,没有必要使用Dockerfile指令将文件复制到卷中。因此,在容器启动之后,仅存在一个的卷。

Volumes are the preferred way to persist data in Docker containers and services. Some use cases for volumes include:

Sharing data among multiple running containers. If you don’t explicitly create it, a volume is created the first time it is mounted into a container. When that container stops or is removed, the volume still exists. Multiple containers can mount the same volume simultaneously, either read-write or read-only. Volumes are only removed when you explicitly remove them.

When the Docker host is not guaranteed to have a given directory or file structure. Volumes help you decouple the configuration of the Docker host from the container runtime.

When you want to store your container’s data on a remote host or a cloud provider, rather than locally.

When you need to back up, restore, or migrate data from one Docker host to another, volumes are a better choice. You can stop containers using the volume, then back up the volume’s directory (such as /var/lib/docker/volumes/).


Reference

关于docker - Docker COPY成功,但经检查无文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57599201/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com