Skip to content

Instantly share code, notes, and snippets.

@MartyMacGyver
Last active July 13, 2025 02:26
Show Gist options
  • Select an option

  • Save MartyMacGyver/4b531fd3b493ebf4e5b3d87026018ca7 to your computer and use it in GitHub Desktop.

Select an option

Save MartyMacGyver/4b531fd3b493ebf4e5b3d87026018ca7 to your computer and use it in GitHub Desktop.
A simple docker compose wrapper for imapsync that runs locally saves an easily accessible log file
services:
imapsync:
image: gilleslamiral/imapsync:latest # Or another imapsync image like jauderho/imapsync
container_name: imapsync_runner
volumes:
- ./config:/config # Optional: Mount a directory for configuration files or scripts
- ./var/tmp/logs:/var/tmp/logs
command: >
imapsync
--host1 mail.olddomain.com --user1 oldme@olddomain.com --password1 'xxxxx'
--host2 mail.newdomain.com --user2 newme@newdomain.com --password2 'yyyyy'
--ssl1 --ssl2
--log
--logdir /var/tmp
--logfile my_migration.log
--dry
# --ssl1 --ssl2 # Use SSL for secure connections
# --delete2 # Optional: Delete messages on host2 that are not on host1
# --exclude 'Junk' # Optional: Exclude specific folders
# --dry # Optional: Perform a dry run without actual synchronization
# run with `docker compose up`
@MartyMacGyver
Copy link
Author

Because /var/tmp is owned by "nobody" in the base image, it's very picky about the directories you mount, thus the weird way I had to do the bind mounts. You have to run it at least once as shown, then CHANGE --logdir to /var/tmp/logs (else it won't save the directory). At that point you might consider a dockerfile to wrap the original docker image with a sane log directory instead of the one also used by the pid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment