How to copy file from host to container using Dockerfile

前端 未结 7 1201
Happy的楠姐
Happy的楠姐 2020-12-13 03:11

I have written a Dockerfile which looks like this

FROM ubuntu:12.04

RUN apt-get update
RUN apt-get install -y wget

Now I\'m having a file

7条回答
  •  臣服心动
    2020-12-13 04:12

    Use COPY command like this:

    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
    

    read more details for COPY in the official documentation

    An alternative would be to use ADD but this is not the best practise if you dont want to use some advanced features of ADD like decompression of tar.gz files.If you still want to use ADD command, do it like this:

    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
    

    read more details for ADD in the official documentation

提交回复
热议问题