Closed dngray closed 1 year ago
@eyduh I am not entirely following the volume declaration. Shouldn't it be something like:
volumes:
- ./protonmail:/root
For the containers, or services as they technically are referred to in a compose file, there can be a section declaring where to store user data. This can either be a named volume, like
volumes:
- protonmail:/root
In which case the volume will need to be declared in a volumes:
section in the compose file.
Another way to store user data is using bind mounts like you have declared in your example. If using bind mounts then you do not need to declare a volume separately.
There are also predefined volumes that get declared in the Dockerfile if one knows that a certain directory will contain data that needs to be persisted for the user.
You can read more about the different ways to persist user data here.. It is technically not needed but if one wants to move this container from one host to another using volumes is one way to do it, also to make sure the setup is persisted between updates or rebuilds of the image and container.
Seeing as there is no need to browse the files of this container, and the user files are a bit sensitive to permissions, I used a docker volume rather than a bind mount for my setup. The service is run as root so the gpg key files are generated in /root in this case so persisting /root in a docker volume made sense to me, but there is no one right way to do things c:
Thank for the very detailed answer @eyduh!
How would one initialize the container with compose? If I initiate using docker run --rm -it -v protonmail:/root shenxn/protonmail-bridge init
and then try to create a docker compose for it, it does not work, docker compose will try to create a new contain with the same name and complain.
@hobbes444 by default docker compose
creates new volumes and networks prefixed with the assigned project name. If you'd rather prefer it to use an existing volume, it should be marked with external: true
:
volumes:
protonmail:
external: true
Thanks @Nexion @eyduh . I did this:
docker run --rm -it -v protonmail:/root shenxn/protonmail-bridge init
then
version: '2.1'
services:
protonmail-bridge:
image: shenxn/protonmail-bridge
container_name: pm_bridge
ports:
- 127.0.0.1:1025:25/tcp
- 127.0.0.1:1143:143/tcp
restart: unless-stopped
stdin_open: true
tty: true
volumes:
protonmail:
external: true
but that does not seem to work, I get this error:
WARN[0000] Failed to add test credentials to keychain error="pass not initialized: exit status 1: Error: password store is empty. Try \"pass init\".\n" helper="*pass.Pass"
It seems it's not able to find the data created using the initialization command.
@hobbes444
version: '2.1'
services:
protonmail-bridge:
image: shenxn/protonmail-bridge
container_name: pm_bridge
ports:
- 127.0.0.1:1025:25/tcp
- 127.0.0.1:1143:143/tcp
volumes: # <---
- protonmail:/root
restart: unless-stopped
stdin_open: true
tty: true
volumes:
protonmail:
external: true
Thanks for the contribution! Sorry for replying late. I'll merge this first and feel free to submit any further improvements
It's quite the norm to include a docker-compose file, generally in the README or the root for people to copy and modify. For example as https://github.com/wfg/docker-openvpn-client has done so.
If there are Environmental variables, they should also be documented - in this case there isn't.