Add bind mount to Dockerfile just like volume

后端 未结 3 1935
青春惊慌失措
青春惊慌失措 2021-02-01 04:38

I want to add the bind mount to docker file just like I initialise a volume inside Dockefile. Is there any way for it?

3条回答
  •  广开言路
    2021-02-01 04:52

    In addition to what the other answers say:

    Because bind mounts provide access to the host filesystem, allowing them to be embedded into an image would be a huge security risk. Consider an image that purports to be, say, a web server, but in fact bind mounts your /etc/passwd and /etc/shadow and then sends them off to a remote server.

    Or one that bind mounts /lib/ld-linux.so and then overwrites it, thus breaking your entire system.

    For these reasons, you cannot embed a a bind mount in your Dockerfile. Similarly, you cannot specify host port mappings, host device access, or any other similar attributes in the Dockerfile.

提交回复
热议问题