Setup Docker for Local Development (Firebase)

December 13, 2019

Install docker

curl -fsSL | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli

Test Docker

sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

Run Docker by non-root user

sudo groupadd docker
sudo usermod -aG docker $USER

NOTE: You need to login and logout again for the new membership permission to take effect. Else, run newgrp docker.

Test without sudo

docker run hello-world

Enable Docker to start on boot

sudo systemctl enable docker

Setup Ubuntu docker to development

docker pull ubuntu

Start Docker image with interactive shell

docker run -it ubuntu

Setup Node 8 runtime

apt install curl

curl -sL -o


apt-get install -y nodejs


node -v
npm -v

Save/Commit Docker Changes

Notice the command prompt root@819af265fe19: /, where 819af265fe19 is the container id. You can check the current container id via docker ps -a (run outside of docker).

Exit docker.


Save the changes as ubuntu:firebase

docker commit -m 'install nodejs & npm' <CONTAINER_ID> ubuntu:firebase

Start docker again with the saved changes

docker run -it ubuntu:firebase

Test if node installation is committed.

node -v

Install Firebase

  • Map docker directory with host directory: /code/firebase/test, thus we could use IDE at host to edit the files.
  • Map port 9005 for firebase login
  • Map port 5000 for firebase hosting
docker run -it -v /code/firebase/test:/code/firebase/test -p 9005:9005 -p 5000:5000 ubuntu:firebase

Install Firebase

npm install -g firebase-tools


firebase login

Firebase init

cd /code/firebase/test

firebase init

Test Hosting

firebase serve -o

NOTE: Cannot access docker from host via localhost, thus need


firebase deploy --only hosting

NOTE: Remember to save/commit docker image after exit, else firebase setup and installation shall be lost.


This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.