I am learning Docker and building a new image. During the build process, I copy a bash script into the docker (let's call it hello.sh) image and then I execute it. This bash script writes something to the output with echo.
I would like to see somehow the output of the hello.sh on my console while building the image.
This is my Dockerfile:
FROM ... COPY .../hello.sh /u01/oracle/ CMD ["/u01/oracle/hello.sh"] Docker build:
docker build -t my-helloworld:1.0 . Output:
Step 6/14 : COPY .../hello.sh /u01/oracle/ ---> 06e7428586b3 ... Step 14/14 : CMD ["/u01/oracle/hello.sh"] ---> Running in fcd495c2e52a Removing intermediate container fcd495c2e52a ---> d21b20deaa26 Successfully built d21b20deaa26 Successfully tagged my-helloworld:1.0 hello.sh
#!/bin/bash echo "I want to see this line on my console while executing docker build..." So I would like to see somehow the output of this internal bash script on my console or at least in a logfile inside the image.
At first, I just started the image with docker run and tried to see the output with docker logs. There was nothing there to see.
Then I gave up to redirect the container output to my console and tried to log the output into a logfile:
CMD ["/bin/bash", "/u01/oracle/hello.sh > hello.log 2>&1"] I tried this as well, hello.sh:
#!/bin/bash exec > hello.log exec 2>&1 echo "I want to see this line on my console while executing docker build..." No one from the above works.
Any suggestions, please?