Why does Docker not attempt to install packages as specified before executing CMD?

Hi,

First off, Docker newbie here!
I’ve built a docker image, exported it into a *.tar file, copied the ttar to a second host, loaded it andran it there and it doesn’t do what I expected it to do. My Dockerfile looks like this where I built the image:
#Dependency
FROM ubuntu:16.04

#Seto working directory
WORKDIR /path

# Copy the current directory contents into the container at /app
ADD . /path

#install dependencies
RUN apt-get update; apt-get install -y \
libpqxx-dev \
libpq-dev \
libcurl4-openssl-dev \
libxml2-dev \
libfftw3-dev \
libsensors4-dev \
libpython-dev \
libtiff-dev \
libjpeg-dev \
libtbb-dev

#extract env directory
RUN /bin/tar -xvjf /path/env.tar.bz2
#define environment variables
#RUN /bin/bash -c "source /path/env/env.sh"

# launch cve
CMD /path/run/start-test-runner.sh path-test-frames 20161130 0 25000 path-temp 20180527

and when I executed it with “docker run MyImage”, I expected it to first install the dependencies with apt but instead it first executed the CMD. Why would it do that? Should it not first on top on go down line by line?
What do I misunderstand?

Both systenms are running Linux version:
Docker version 18.06.1-ce, build e68fc7