title: Docker run command with environment variables
body: <p>I'm trying to launch a docker container that will execute a command like this:</p>
  
  <pre><code>docker run --net="host" -it --entrypoint bash $KAFKA_DOCKER_IMAGE "\$KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper localhost:2181 --topic $1 --partitions $num_partitions --replication-factor $replication_factor"
  </code></pre>
  
  <p>Where $KAFKA_DOCKER_IMAGE, $replication_factor and $num_partitions are variables defined in a script that I'm using to execute this command. And $KAFKA_HOME is an environment variable that is already defined in the docker image.</p>
  
  <p>My problem is that the command that is being executed on the container is the following:</p>
  
  <pre><code>$KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper localhost:2181 --topic popota --partitions 1 --replication-factor 1
  </code></pre>
  
  <p>It doesn't expand the $KAFKA_HOME.
  How can I do this?</p>