Piping a file into docker run

后端 未结 2 1796
野性不改
野性不改 2021-01-31 14:08

I need to pipe (inject) a file or some data into docker as part of the run command and have it written to a file within the container as part of the startup. Is there best pract

相关标签:
2条回答
  • 2021-01-31 14:49
    cat setup.json |  docker run -i  ubuntu /bin/bash -c 'cat'
    

    This worked for me. Remove the -t. Don't need the -a's either.

    0 讨论(0)
  • 2021-01-31 14:56

    The better solution is to make (mount) you host folder be accessible to docker container. E.g. like this

    docker run -v /Users/<path>:/<container path> ... 
    

    Here is /Users/<path> is a folder on your host computer and <container path> mounted path inside container.

    Also see Manage data in containers manual page.

    UPDATE another Accessing External Files from Docker Containers example.

    0 讨论(0)
提交回复
热议问题