Mailhog, I can't set maildir and have persist data

Hi all,
I installed on Oracle Linux 8.3 Docker CE Engine

After I created a volume with this command:
docker volume create docker-maildir

I installed the container MAILHOG and force to use my volume with this command:
docker run -d -p 25:1025 -p 2080:8025 -v docker-maildir:/maildir --name mailhog --restart unless-stopped mailhog/mailhog

but if I restart the container I lost the inbox emails.

I tried to access to the container with the command:
docker exec -it mailhog /bin/sh

But I don’t see any emails in the folders.

How can set -storage?

I think this should maybe be asked on the mailhog github, since its not directly docker related.
but, reading what you supplied, i see that:

| Environment         | Command line    | Default         | Description
  MH_STORAGE          | -storage        | memory 

so maybe change that variable to “maildir”, else it seems like it will save to memory

Hi tepz,
thank you for your reply.

I solved with this command:

docker run -d -p 25:1025 -p 2080:8025 -v mailhog-maildir:/home/mailhog/maildir -v mailhog-smtpconf:/smtp_conf -e MH_STORAGE=maildir -e MH_MAILDIR_PATH=maildir -e MH_OUTGOING_SMTP=/smtp_conf/smtp.json --restart unless-stopped --name mailhog mailhog/mailhog

But I have to set the permission for the volume as 777 otherwise from mailhog I can’t write emails to the volume mounted.

Marco

For the volume?
I would set the path to /maildir, so it isnt in the home/mailhog path, but again, its just my 2 cents :wink:

Hi Martin,
thank you so much for your reply and your time.

I started few time ago to studi docker, and I’m not very expert.

I mapped correctly the folder, /mail dir on the container is in /home/mailhog/maildir and it is mapped correctly with my volume mailhog-maildir.

Now, is I set the permission on _data folder for mailhog-maildir as 777 from container I can write on it, also I can’t.

Thanks
Marco