Run a script in Dockerfile

后端 未结 5 1078
无人及你
无人及你 2020-12-22 22:34

I\'m trying to run a script during my building process in my Dockerfile. But it doesn\'t seems to work.

I tried that way:

FROM php:7-fpm
ADD bootstra         


        
5条回答
  •  孤城傲影
    2020-12-22 22:51

    It's best practice to use COPY instead of ADD when you're copying from the local file system to the image. Also, I'd recommend creating a sub-folder to place your content into. If nothing else, it keeps things tidy. Make sure you mark the script as executable using chmod.

    Here, I am creating a scripts sub-folder to place my script into and run it from:

    RUN mkdir -p /scripts
    COPY script.sh /scripts
    WORKDIR /scripts
    RUN chmod +x script.sh
    RUN script.sh
    

提交回复
热议问题