'Docker file RUN multiple sed commands
I am trying to change several configuration items in a single file that is part of an existing Docker image using the following RUN command:
RUN sed --in-place '/start_rpc:/ s/false/true/g' /etc/cassandra/cassandra.yaml &&\
sed --in-place '/broadcast_rpc_address:/ s/172.17.0.2/192.168.1.248/g' /etc/cassandra/cassandra.yaml &&\
sed --in-place '/listen_address:/ s/172.17.0.2/192.168.1.248/g' /etc/cassandra/cassandra.yaml &&\
sed --in-place '/seeds:/ s/172.17.0.2/192.168.1.248/g' /etc/cassandra/cassandra.yaml
I am sure the multiple sed commands are fine as I can run them on the host's console and achieve the 4 changes I am trying to execute.
The docker build does not show any errors and, in fact, it generates a new image. However, when I run the container and login to it, I can see that only the first of the four replacements took place.
I have already tried several combinations, including a compound sed such as:
RUN sed --in-place '/start_rpc:/ s/false/true/g; /broadcast_rpc_address:/ s/172.17.0.2/192.168.1.248/g; /listen_address:/ s/172.17.0.2/192.168.1.248/g; /seeds:/ s/172.17.0.2/192.168.1.248/g' /etc/cassandra/cassandra.yaml
And also four individual RUN commands. In all cases the result was the same: start_rpc is changed to true but not one of the other IP addresses gets changed.
Does anyone have any idea what could be wrong here and, if so, why docker build does not report something useful (and preferably fails)?
Solution 1:[1]
The answer to these problems can be found here but, in a nutshell, once the container starts, additional scripts are run to complete the set up of Cassandra and IP addresses are the typical type of configuration that can only be discovered once the container starts.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | quiet-ranger |
