I'm creating a Docker image where I use sed
to modify two parameters, but when i create the images and check the file I want to modify it remains the same.
If i run the very sed command interactively, it works. Why? Could somebody help me make my image work without having to modify every container?
Before I was pointed a mistake in this point because i was using exit in before another command in the RUN command, now sed is an independent command and still doesn't work.
Dockerfile
FROM python:slim-buster
WORKDIR /home/scr_dca
COPY . .
ENV FLASK_APP Screenly.py
RUN su && \
apt-get update && \
apt install curl gnupg -y && \
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17 unixodbc-dev -y && \
apt-get install libgssapi-krb5-2 && \
exit && \
pip3 install -r requirements.txt --trusted-host pypi.python.org && \
sed -i "s/\(MinProtocol *= *\).*/\1TLSv1.0 /" "/etc/ssl/openssl.cnf" && \
sed -i "s/\(CipherString *= *\).*/\1DEFAULT@SECLEVEL=1 /" "/etc/ssl/openssl.cnf"
CMD ["gunicorn", "-b", ":8000", "scr_dca:app"]
I'm doing:
docker run --name screenly_dca3 -d -p 5050:8000 src_dca_v1.0
docker container exec -it screenly_dca3 bash
- then in bash:
cat /etc/ssl/openssl.cnf
I checked sed has not worked yet during the image creation and I ran the following commands:
sed -i "s/\(MinProtocol *= *\).*/\1TLSv1.0 /" "/etc/ssl/openssl.cnf"
sed -i "s/\(CipherString *= *\).*/\1DEFAULT@SECLEVEL=1 /" "/etc/ssl/openssl.cnf"
original part of the file I want to modify:
[system_default_sect]
MinProtocol = TLSv1.2
CipherString = @SECLEVEL=1
sed expected result
[system_default_sect]
MinProtocol = TLSv1.0
CipherString = DEFAULT@SECLEVEL=1