Docker Community Forums

Share and learn in the Docker community.

Dockerfile - pick up a docker run option and edit a file

Today I decided to create my first docker container. I read some guides and started working on a Dockerfile that will install a Rundeck container.

FROM ubuntu:18.04
MAINTAINER namehere <>

RUN apt-get update && apt-get install -y wget openjdk-11-jdk uuid-runtime openssh-client apt-utils && apt-get clean
RUN wget
RUN dpkg -i rundeck_3.2.5.20200403-1_all.deb
RUN sed -i -e 's/localhost/$SERVER_IP/g' /etc/rundeck/ /etc/rundeck/

VOLUME ["/etc/rundeck"]
VOLUME ["/var/lib/rundeck"]
VOLUME ["/var/log/rundeck"]


CMD service rundeckd start && tail -F /var/log/rundeck/service.log

My issue here is that when a user installs the container, they need to define an option that will in turn define the $SERVER_IP variable, which need to be modified in 2 files, as shown above.

Ideally the container would be installed using a command like this.

docker run -d \
 --restart=always \
 --name rundeck \
 -h rundeck \
 -e PUID=1001 \
 -e PGID=1001 \
 -e TZ=Europe/Nicosia \
 --net=network \
 -p 4440:4440 \
 -e SERVER_IP= \

How can I achieve this?