Run a script in Dockerfile

后端 未结 5 1079
无人及你
无人及你 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 23:08

    Try to create script with ADD command and specification of working directory Like this("script" is the name of script and /root/script.sh is where you want it in the container, it can be different path:

    ADD script.sh /root/script.sh
    

    In this case ADD has to come before CMD, if you have one BTW it's cool way to import scripts to any location in container from host machine

    In CMD place [./script]

    It should automatically execute your script

    You can also specify WORKDIR as /root, then you'l be automatically placed in root, upon starting a container

提交回复
热议问题