How do I use Docker and Dropbox to run multiple instances?
Settin Up Docker And Dropbox
Shivam Kapoor created an excellent blog post on how to setup Dropbox using Docker to allow multiple instances to function on a system. I made some minor changes and used this to setup a laptop so I can work with multiple copies of Dropbox without issue.
How To
- Install Docker.
Use your package manager to install Docker.$ sudo pacman -S docker - Setup your user.
Setup your user by adding them to the$ sudo usermod -aG docker $USERdockergroup. This is so you don’t have to usesudoto work with Docker. - Get the Docker Image
User janeczku created a docker image that runs dropbox. Review the code yourself.$ docker pull janeczku/dropbox - Create the Docker Machine and the volume
You need to edit the name of the machine, the locations you want to use for the volumes, and the UID/GID so you don’t run into permissions issues. If your user is$ docker run -d --restart=always --name=RENAMETHIS -v /home/aaronj/Dropbox:/dbox/Dropbox -v /home/aaronj/.dropbox:/dbox/.dropbox -e DBOX_UID=1000 -e DBOX_GID=1000 janeczku/dropboxaaronjyou would docat /etc/passwd | grep "aaronj"and use the UID/GID displaye so you don’t run into permissions issues. If your user isaaronjyou would docat /etc/passwd | grep "aaronj"and use the UID/GID displayed. - Register the Docker Account
$ docker logs RENAMETHIS - Look for a line that says something like -
https://www.dropbox.com/cli_link_nonce?nonce=612531228134bf411986991sdd4d69438
Click it and login to register your Dropbox account with that container.
7. Restart the docker machine
$ docker restart RENAMETHIS
8. Wait for the box to sync.
9. Fix the file permissions.
$ sudo chmod 755 /home/aaronj/Dropbox -R $ sudo chmod g+s /home/aaronj/Dropbox -R $ sudo chown aaronj:aaronj /home/aaronj/Dropbox -R
This resolved my issue and with the laptop being a single user system, I am unconcerned about the permissiveness of the settings because my system is a single user box with disk encryption. You may want to write a cron to restart the box every 10-15 minutes as well. The Dropbox daemon seems to have some issues within the container and it helps to just restart the container.
Troubleshooting
- How do I restart my dropbox machine?
$ docker container ls
You will want to find the name of the container you need. 2. Then restart the machine.
$ docker restart NAMEOFTHEMACHINE
This usually solves the issue. You can also create a cronjob that restarts regularly to solve any issues off the bat.
$ sudo crontab -s
# Edit the crontab to look like this -
# This restarts the container every 10 minutes. Edit this as you see fit.
*/10 * * * * /usr/bin/docker restart RENAMETHIS