by Todd Appleton, updated by Erik Jacobsen • May 19, 2018
Note: We have updated the instructions here to match our DF-Docker repo instructions. This will pull the latest GitHub repo now.
DreamFactory can be run as a Docker container, which makes it easier than ever to get the backend for your apps up and running. The DreamFactory Docker image is available on Docker Hub, or you can build your own image from the GitHub repo. Using these two methods, I’ll show you how to use Docker to fire up your own DreamFactory instance in just a few steps. This setup uses MySQL for the system database and Redis for the system cache. The basic idea is that you first start the containers for MySQL and Redis, then a container for DreamFactory which links to the others.
The DreamFactory image on Docker Hub is an automated build based on our df-docker repo on GitHub. It’s a basic DreamFactory install, meaning that it doesn’t include drivers for some services like MS SQL or Oracle. If you need to customize your image with extra drivers all you need to do is clone the GitHub repo and build your own image that includes those extra drivers. See Method 2 below. Note that all the provided database credentials are defaults and you should change them.
The easiest way to configure the DreamFactory application is to use docker-compose.
cd ~/repos (or wherever you want the clone of the repo to be)git clone https://github.com/dreamfactorysoftware/df-docker.gitcd df-docker
git clone https://github.com/dreamfactorysoftware/df-docker.git
docker-compose up -d
NOTE: volume df-storage:/opt/dreamfactory/storage is created to store all file based (apps, logs etc.) data from DreamFactory.
This basically stores all data written by DreamFactory (at /opt/dreamfactory/storage location) in the df-storage volume. This
way if you delete your DreamFactory container your data will persist as long as you don't delete the df-storage volume.
to stop and remove all containers you can use the command
to stop and remove all containers including volumes use
docker-compose down -v
Go to 127.0.0.1 in your browser. It will take some time the first time. You will be asked to create your first admin user.
If you don’t want to use docker-compose you can build the images yourself.
cd ~/repos (or wherever you want the clone of the repo to be)
git clone https://github.com/dreamfactorysoftware/df-docker.gitcd df-docker
docker build -t dreamfactory .
docker run -d --name df-mysql -e "MYSQL_ROOT_PASSWORD=root" -e "MYSQL_DATABASE=dreamfactory" -e "MYSQL_USER=df_admin" -e "MYSQL_PASSWORD=df_admin" mysql
docker run -d --name df-redis redis
If your database and redis runs inside another container you can simply link it under the name db and rd respectively.
docker run -d --name df-web -p 80:80 -e "DB_DRIVER=mysql" -e "DB_HOST=db" -e "DB_USERNAME=df_admin" -e "DB_PASSWORD=df_admin" -e "DB_DATABASE=dreamfactory" -e "CACHE_DRIVER=redis" -e "CACHE_HOST=rd" -e "CACHE_DATABASE=0" -e "CACHE_PORT=6379" --link df-mysql:db --link df-redis:rd dreamfactory
for Docker commands depending on your setup.
With the DreamFactory container running you can access your instance’s admin console by going to https://127.0.0.1 in your browser. The first time you’ll be asked to create an admin user for your instance. Use this email and password to login to the admin console. That’s all there is to it. Now you’re ready to start building apps using the REST API at, in this case, https://127.0.0.1/api/v2. From this point on you can use the Docker CLI commands to manage the containers.
Join the DreamFactory newsletter list.