Docker Community Forums

Share and learn in the Docker community.

Run commands on Dockerfile are not working

I have the following Dockerfile. When I run the Dockerfile, the commands seem to execute without any issues, but when I login in to the container the file is unchanged. Any idea why this is happening? If I login into the container directly and I execute the commands they execute without any issues and update the file. The problem is building the image, the files /etc/kamailio/kamctlrc and /etc/kamailio/kamailio.cfg are unchanged.

FROM kamailio/kamailio:5.2.8-stretch

# To use MYSQL as DB 
RUN sed -i 's/# DBENGINE=MYSQL/DBENGINE=MYSQL/g' /etc/kamailio/kamctlrc 
 
# DB access
RUN sed -i 's/# DBRWUSER="kamailio"/DBRWUSER="kamailio"/g' /etc/kamailio/kamctlrc 
RUN sed -i 's/# DBRWPW="kamailiorw"/DBRWPW="kamailiorw"/g' /etc/kamailio/kamctlrc 
RUN sed -i 's/# DBROUSER="kamailioro"/DBROUSER="kamailioro"/g' /etc/kamailio/kamctlrc 
RUN sed -i 's/# DBROPW="kamailioro"/DBROPW="kamailioro"/g' /etc/kamailio/kamctlrc 

RUN sed -i 's/#CHARSET="latin1"/CHARSET="utf8"/g' /etc/kamailio/kamctlrc 
RUN sed -i 's/# DBPORT="3306"/DBPORT="3306"/g' /etc/kamailio/kamctlrc 

#SET EXTRA TABLES
RUN sed -i 's/# INSTALL_EXTRA_TABLES=ask/INSTALL_EXTRA_TABLES=yes/g' /etc/kamailio/kamctlrc 
RUN sed -i 's/# INSTALL_DBUID_TABLES=ask/INSTALL_DBUID_TABLES=yes/g' /etc/kamailio/kamctlrc 
RUN sed -i 's/# INSTALL_PRESENCE_TABLES=ask/INSTALL_PRESENCE_TABLES=yes/g' /etc/kamailio/kamctlrc 
 
# DB DOCKER HOST
RUN sed -i 's/# DBHOST=localhost/DBHOST=mariadb/g' /etc/kamailio/kamctlrc 
 
# To enable usage of MySQL 
RUN sed -i -e '1i#!define WITH_MYSQL\' /etc/kamailio/kamailio.cfg 
RUN sed -i -e '2i#!define WITH_AUTH\' /etc/kamailio/kamailio.cfg 
RUN sed -i -e '3i#!define WITH_USRLOCDB\' /etc/kamailio/kamailio.cfg 


ENTRYPOINT ["kamailio","-DD","-E"]

Hi mirjoli021 sounds like an issue with the permissions. Maybe try to change user to root before running SEDs?

If you look at your build, you can see the ssh service start in an intermediate container which is deleted in the next build step:

—> Running in a1afe0c2ce71

  • Starting OpenBSD Secure Shell server sshd [ OK ]
    Removing intermediate container a1afe0c2ce71
    To start a service in a Dockerfile, you should use either a CMD or ENTRYPOINT statement as the last line (depending on whether you might want to pass an argument in the docker run … command, normally.

Generally, a service will start in the background as a daemon however, so having this as your last line:

CMD [“service”, “ssh”, “start”]
Will not work, as the container will exit as it has nothing do to

What you probably want (from the docker docs) is this:

CMD ["/usr/sbin/sshd", “-D”]
Which starts the service in the foreground so that the container will stay alive

This link has useful info about the difference between CMD & ENTRYPOINT, and also the difference between the exec & shell formats.