redirect input into dockerfile


docker build -t myimage:latest  -f- . <<EOF
FROM centos
CMD mkdir /app
WORKDIR /app
RUN echo "file contents" > file.txt
EOF

Sending build context to Docker daemon  16.43kB
Step 1/4 : FROM centos
 ---> 470671670cac
Step 2/4 : CMD mkdir /app
 ---> Using cache
 ---> cf9be82aca00
Step 3/4 : WORKDIR /app
 ---> Using cache
 ---> 24baea1f7712
Step 4/4 : RUN echo "file contents" > file.txt
 ---> Using cache
 ---> 61db761dc411
Successfully built 61db761dc411
Successfully tagged myimage:latest

docker run --name ttt -ti -d --privileged=true myimage  "/sbin/init"
docker exec -it ttt cat '/app/file.txt'
file contents


Views All Time
Views All Time
41
Views Today
Views Today
2

Leave a Reply

Your email address will not be published. Required fields are marked *