How can I set $PS1 with Dockerfile?

What is happening here is that PS1 is being redefined by the file ~/.bashrc that is in your image and automatically sourced on start up of your container (it could be on another file - I am not sure if PS1 always get defined in ~/.bashrc on all linux distros).

Assuming it is defined in ~/.bashrc, then you could write in your Dockerfile a RUN command that could look like:

RUN echo PS1=\"\\h:\\W \\u$ \" >> ~/.bashrc

Et voila!