FAQs 1: How execute bash script line by line?

You don't need to put a read in everyline, just add a trap like the following into your bash script, it has the effect you want, eg.
#!/bin/bash

set -x
trap read debug

< YOUR CODE HERE >

FAQs 2: How to Pass Environment Variable Value into Dockerfile?

Dockerfile provides a dedicated variable type ENV to create an environment variable. We can access ENV values during the build, as well as once the container runs.

There are two different ways to pass Environment Variable:

Way 1: Hardcoding Environment Values

The simplest way to pass environment value is to hardcode it in the Dockerfile. This can be good enough in some cases. Let's hardcode John as a default name in our Dockerfile:
FROM alpine:latest

ENV env_name John

COPY greetings.sh .

RUN chmod +x /greetings.sh

CMD ["/greetings.sh"]
Now, let's build and run our image. Here's the desired console output:
Hello John
Way 2: Setting Dynamic Environment Values

Dockerfile does not provide a dynamic tool to set ENV value during the build process. However, there is a solution to this problem. We have to use ARG. ARG values do not work in the same way as ENV, as we can’t access them anymore once the image is built.

Let's see how we can work around this issue:
ARG name
ENV env_name $name
We're introducing the name ARG variable. After that, we're using it to assign a value to the env_name environment variable using ENV.

When we want to set this argument, we pass it with the --build-arg flag:
docker build -t baeldung_greetings --build-arg name=Baeldung .
Now, let's run our container. We should see:
Hello Baeldung
What if we want to change the name? All we have to do is just rebuild the image with a different build-arg value.

FAQs 3: How to remove old/stray PID files before starting a docker container?

When starting any docker container, it creates a PID file. A PID, shorthand for Process ID, is a file that contains only the ID of the server process on the operating system.

At sometimes, when you restart a docker container especially when using docker-compose, the container fails to restart because of existing old pid file.

The most straightforward way is to remove the PID file before we kick-off the docker container. It can be done by modifying the CMD of the Dockerfile:

Just remove the old pid file in CMD using shell mode. The below code for removing old pgpool-ii pid file before starting the pgpool container:

Old Docker CMD instruction:
CMD ["pgpool", "-n"]
New Docker CMD instruction:
CMD rm -f /var/run/postgresql/pgpool.pid; pgpool -n