What are advantages of writing script file in Docker?

What are advantages of writing commands inside script file and running that script in Dockerfile rather than directly writing instructions inside Dockerfile ?

  • How to properly share a folder between few docker containers in read mode?
  • Connect to docker containers with just service name and task slot?
  • dumb-init No such file or directory
  • Aborted connection to db; docker-compose ruby & mysql images - Got an error reading communication packets
  • MupX, graphicsmagick and env var
  • mounting local home directory in Rstudio docker?
  • How can we use shared Dockerfile's which reside in different directories than the “current build context path”?
  • Docker container can reach DNS but not resolve hosts
  • How can I mount host directory as container volume for mongodb container?
  • Access Jupyter notebook running on Docker container
  • 502 bad gateway with nginx and node inside docker
  • kubectl get pods - kubectl get pods - STATUS ImagePullBackOff
  • One Solution collect form web for “What are advantages of writing script file in Docker?”

    I assume you are referring to writing a script like


    instead of directly writing

    RUN cmd1
    RUN cmd2
    RUN cmd3

    in the Dockerfile. The benefit is that each RUN command executes a separate script. By writing a single script, you only need to execute one script. This gives both better performance, and allows you to share data via variables from one command to the next.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.