如何使用Dockerfile将文件从主机复制到容器
我写了一个Dockerfile,看起来像这样
FROM ubuntu:12.04 RUN apt-get update RUN apt-get install -y wget
现在我在主机中有一个名为abc.txt
的文件。 我怎样才能把它复制到这个容器。 是否有任何步骤,我可以在Dockerfile中添加从主机复制到容器。
像这样使用COPY命令:
COPY foo.txt /data/foo.txt # where foo.txt is the relative path on host # and /data/foo.txt is the absolute path in the image
在官方文档中阅读COPY的更多细节
另一种方法是使用ADD,但如果您不想使用ADD的某些高级function(如tar.gz文件的解压缩),则这不是最佳做法。如果您仍想使用ADD命令,请执行下列操作:
ADD abc.txt /data/abc.txt # where abc.txt is the relative path on host # and /data/abc.txt is the absolute path in the image
在官方文档中阅读ADD的更多细节
I faced this issue, I was not able to copy zeppelin [1GB] directory into docker conatiner. and getting issue "COPY failed: stat /var/lib/docker/tmp/docker-builder977188321/zeppelin-0.7.2-bin-all: no such file or directory" I am using docker Version: 17.09.0-ce and resolved issue by following steps. Step 1: copy zeppelin directory [which i want to copy into docker package]into directory contain "Dockfile" Step 2: edit Dockfile and add command [location where we want to copy] ADD ./zeppelin-0.7.2-bin-all /usr/local/ Step 3: go to directory which contain DockFile and run command [alternatives also available] docker build . Step 4: docker image created Successfully with logs Step 5/9 : ADD ./zeppelin-0.7.2-bin-all /usr/local/ ---> 3691c902d9fe Step 6/9 : WORKDIR $ZEPPELIN_HOME ---> 3adacfb024d8 .... Successfully built b67b9ea09f02
- 错误:(gcloud.preview)无效select:“docker”。 你的意思是'dm-v2'?
- 将容器图像推送到Service Fabric图像存储区
- 有没有一种方法可以避免使用Docker推送node_modules?
- docker私人registry:ping尝试失败
- gclouddocker推送可靠性
- 如何从Tutum私有registry中将Amazon Docker的Docker镜像拖放到Amazon ECS?
- 获取部署Kubernetes服务的YAML?
- 如何从外部世界连接到docker集装箱
- Jenkinspipe道用Docker,Google Registry和Google Auth Plugin构build