Skip to content

7. Docker Container for MobSF Static Analysis

Ajin Abraham edited this page May 16, 2019 · 13 revisions

Building Image from Dockerfile

git clone
cd Mobile-Security-Framework-MobSF
docker build -t mobsf .
docker run -it -p 8000:8000 mobsf

This will run MobSF at

Building Image behind a proxy from Dockerfile

docker build --build-arg https_proxy="http://proxy_ip:proxy_port" --build-arg http_proxy="proxy_ip:proxy_port" --build-arg NO_PROXY="" -t mobsf .

(replace `proxy_ip` with the value of your proxy ip address and `proxy_port` with the proxy port used 

Rebuilding Image from Dockerfile from Scratch

docker rmi ubuntu:18.04
docker build --no-cache --rm -t mobsf .

Prebuilt MobSF Docker Image

docker pull opensecurity/mobile-security-framework-mobsf
docker run -it -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest

For persistence

docker run -it -p 8000:8000 -v <your_local_dir>:/root/.MobSF opensecurity/mobile-security-framework-mobsf:latest

For postgres support

You will need docker-compose : see

  • build the images docker-compose build
  • launch the services docker-compose up -d (in background) or docker-compose up (in foreground )

Then verify the 2 services are up:

docker ps

CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                          NAMES
7de107c5b853        mobile-security-framework-mobsf_mobsf   "python3 r…"   5 weeks ago         Up 5 weeks>8000/tcp         mobile-security-framework-mobsf_mobsf_1
149a3ffa61ca        postgres:latest                         "docker-entrypoint.s…"   5 weeks ago         Up 5 weeks          5432/tcp                       mobile-security-framework-mobsf_postgres_1

If you don't want to use docker-compose, you will need to start a postgres container first , then to start MobSF using the dockerfile and setting POSTGRES variable to True

docker build --build-arg POSTGRES=True -t mobsf .

You can change postgres connection information in Do it before building the image

set -e
echo "Postgres support : ${POSTGRES}"
if [ "$POSTGRES" == True ]; then
 echo "Installing Postgres"
 pip3 install psycopg2-binary
 #Enable postgres support
 sed -i '/# Sqlite3 suport/,/# End Sqlite3 support/d' ./MobSF/ && \
 sed -i "/# Postgres DB - Install psycopg2/,/'''/d" ./MobSF/ && \
 sed -i "/# End Postgres support/,/'''/d" ./MobSF/ && \
 sed -i "s/'PASSWORD': '',/'PASSWORD': 'password',/" ./MobSF/ && \
 sed -i "s/'HOST': 'localhost',/'HOST': 'postgres',/" ./MobSF/

If you have error at first Launch

docker exec -it mobile-security-framework-mobsf_mobsf_1 python3 makemigrations
docker exec -it mobile-security-framework-mobsf_mobsf_1 python3 migrate
You can’t perform that action at this time.