Docker Community Forums

Share and learn in the Docker community.

Dockerfile is almost an install script

This is probably a dumb question because I’m kinda new to Docker.

I have a working and debugged docker file with lots of apt installs and other goodies that I know works correctly.

Now if I want the same or very similar set of installs but for some reason I cannot run it under docker, I ask myself, why can’t I “execute” the docker file directly to install the same stuff?

Because I find myself going to create an elaborate bash script by copy and pasting (more or less) steps out of the docker file?

Since instructions in Dockerfiles can be multiline instructions, it won’t be easy to find a way to automaticly transform the Dockerfiles into bash scripts…

Maybe this is a good starting point for a transformation script:

sed -r -e "s/^(FROM|ARG|WORKDIR|CMD|VOLUME|LABEL)\s/# \1 /g" -e "s/^ENV/export/g" -e "s/^COPY/cp/g" -e "s/RUN//g" Dockerfile