Moz://a gateway data get wiped every restart of Docker

Well hello, Moz://ians
I have problems with Mozi//a gateway running on Docker when I restart my computer. It seems it wipes all gateway’s data each restart of Docker.
This is quite annoying because I have to sign-up, install add-ons, and redo everything each and every time I restart my computer.
Here is how I ran Mozilla gateway over Docker:

docker run -d -p 8080:8080 -p 4443:4443 -e TZ=America/Los_Angeles -v /path/to/shared/data:/home/node/.mozilla-iot --log-opt max-size=1m --log-opt max-file=10 --name webthings-gateway --restart always mozillaiot/gateway:latest

I’ve added --restart always to get the gateway running when Docker restarts because without this part, the gateway doesn’t start automatically.
I’m not sure whether the problem is related to Docker or my operating system because I ran it on the computer of my brother without any problems.
Thanks in advance
Nas

My OS: Windows 10 x64 2004
Gateway version: 0.12.0

The problem is this:

-v /path/to/shared/data:/home/node/.mozilla-iot

/path/to/shared/data needs to be some actual location on the Docker host.

@mrstegeman
Ahh Okay.
But it worked for me on the other laptop as I mentioned previously.

This is my docker start command that I use. Note that the /mnt/EdbergFS is a persistent USB dongle that mounts at RPI startup using /etc/fstab. It is where I store files and logs across reboots. Using a USB also help prevent SD card wear as the log files are stored on the USB.

# ------------------------------------------------------------------
#  --privileged is not required when --device /dev/ttyACM0:xxx is provided
#  Cannot  share volume in /etc/localtime since that is a symlink.
#  -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \
#  Only really need to specify -e TZ=xxx or -v /etc/timezone:xxx.  Either correctly sets TZ.
# ------------------------------------------------------------------

docker rm mozilla-iot-gateway

docker run -d --restart always --net=host \
        -e TZ=America/Chicago \
        --device /dev/ttyACM0:/dev/ttyACM0 \
        --log-opt max-size=1m \
        --log-opt max-file=5 \
        -v /etc/timezone:/etc/timezone:ro \
        -v /mnt/EdbergFS/mozilla-iot:/home/node/.mozilla-iot \
        --name mozilla-iot-gateway mozillaiot/gateway:latest

Edit:

FYI: This is the /etc/fstab entry that mounts the EXT4-formatted USB across reboots:

PARTUUID=0e620ec0-01 /mnt/EdbergFS ext4 defaults,nofail 0 0

You can identify the partition UUID by the command: lsusb
If you don’t specify the partition id the USB dongle may obtain a different device name and won’t mount consistently.

@EricEdberg, thanks for your feedback.
I’m still hibernating my laptop to preventing data from being wiped because I couldn’t resolve this problem.
I’ll try it out and get back to you as soon as possible.

@EricEdberg, may I know why you didn’t specify the listening port number ?

I did not worry about port mapping between the container and server as the: --net=host, option maps the servers network to the container network without restriction (I think).

If I was worried about the security of the IOT GW running in the container, removing the --net option and specifying a port map would be required and lock down incoming connections to the container image (I think).

My home network is private, can only be accessed using SSH certificates from the internet, and I’m not worried about my others servers/computers breaking into my RPI and/or IOT Container :slight_smile:.

To what should I change this address as I’m not using any USB dongle? I’m just running the gateway on my Windows 10 (laptop).

As @mrstegeman noted in his first reply, you should specify any folder on the W10 laptop that is persistent across reboots. As an example, you could create a folder: C:\Mozilla-IOT-GW, and replace /mnt/EdbergFS in the example command.

You will first have to copy the contents of: /home/node/.mozilla-iot, from inside the running GW container, to: C:\Mozilla-IOT-GW. SCP is your friend copying contents from inside the container to another computer…

Special thanks to @EricEdberg and @mrstegeman.
The problem solved.

Do tell… what the solution to your issue was. It’s always nice to obtain a resolution summary for those reading this in the future.

My bad. Thanks for the reminder.
The command that has solved my issue is:
docker run -d -p 8080:8080 -p 4443:4443 -e TZ=America/Los_Angeles -v E:\Mozilla_Gateway_Data:/home/node/.mozilla-iot --log-opt max-size=1m --log-opt max-file=10 --name webthings-gateway --restart always mozillaiot/gateway:latest
Where: -v E:\Mozilla_Gateway_Data is the folder path where the gateway stores data such as add-ons, floor plans…etc.