I'm trying to build the following Dockerfile:
FROM alpine:latest
EXPOSE 9050 9051
RUN apk --update add tor
RUN echo "ControlPort 9051" >> /etc/tor/torrc
RUN password_hash=$(tor --hash-password "foo")
RUN echo "HashedControlPassword $password_hash" >> /etc/tor/torrc
CMD ["tor"]
I'm trying to add the line HashedControllPassword [pw] to /etc/tor/torrc, where [pw] is generated by the command tor --hash-password "foo". (I'm using "foo" as password in this example).
If I build the image using docker build --tag my_tor . and enter the command line using
docker run -it my_tor /bin/ash
and run cat /etc/tor/torrc, I see
ControlPort 9051
HashedControlPassword
In other words, in the end the torrc doesn't seem to contain the hashed password. However, similar commands in my Ubuntu terminal do work. Can anyone spot what the problem is?
ENV password_hash xxxor something similar, as What you do is only valid in this RUN and not later