You add to use Docker’s volume in order to get data live more longer than Docker’s machine.
For example:
mkdir -p /Users/username/letsencrypt/etc/letsencrypt
mkdir -p /Users/username/letsencrypt/var/lib/letsencrypt
mkdir -p /Users/username/letsencrypt/var/log/letsencrypt
docker run -it --rm -p 443:443 -p 80:80 --name letsencrypt \
-v "/Users/username/letsencrypt/etc/letsencrypt:/etc/letsencrypt" \
-v "/Users/username/letsencrypt/var/lib/letsencrypt:/var/lib/letsencrypt" \
-v "/Users/username/letsencrypt/var/log/letsencrypt:/var/log/letsencrypt" \
quay.io/letsencrypt/letsencrypt:latest certonly --authenticator manual \
--agree-dev-preview --server https://acme-v01.api.letsencrypt.org/directory \
--email username@mydomain.tld --agree-tos --rsa-key-size 4096 \
--renew-by-default --domain mycert.mydomain.tld
This way data will remain on your machine under /Users/username/letsencrypt folder.
log folder is useful with --debug and --verbose parameters when trying to understand why something is going wrong.