Why Permission denied when start a container with ssl support?
Hello Guys,
i have setup a letsencrypt Certificate for mongodb with these instructions
the ca.pem and mongo.pem files i have put into a folder (/mongo-cluster/ssl) on my host machine with these permissions:
drw------- 2 mongodb mongodb 4.0K Sep 2 14:33 . drwxr-xr-x 6 mongodb mongodb 4.0K Sep 2 14:48 .. -rw------- 1 mongodb mongodb 6.5K Sep 2 13:54 ca.pem -rw------- 1 mongodb mongodb 3.9K Sep 2 13:54 mongo.pem
the user and group mongodb have the id 999 (same as in the container).
now i start the container by running
docker run --name mongo1 --hostname mongo1 --network mongodb-cluster
-v /mongo-cluster/mongo1:/data
-v /mongo-cluster/ssl:/etc/ssl
-p 127.0.0.1:17017:27017
--restart always
--env-file /mongo-cluster/env
-d mongo --smallfiles
--auth
--keyFile /data/keyfile/mongo-keyfile
--replSet "rs0"
--storageEngine wiredTiger
--port 27017
--sslMode requireSSL
--sslCAFile /etc/ssl/ca.pem
--sslPEMKeyFile /etc/ssl/mongo.pem
the output was:
2018-09-02T12:46:05.006+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2018-09-02T12:46:05.008+0000 E NETWORK [main] cannot read certificate file: /etc/ssl/mongo.pem error:0200100D:system library:fopen:Permission denied 2018-09-02T12:46:05.008+0000 F CONTROL [main] Failed global initialization: InvalidSSLConfiguration: Can not set up PEM key file. 2018-09-02T12:46:07.189+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2018-09-02T12:46:07.191+0000 E NETWORK [main] cannot read certificate file: /etc/ssl/mongo.pem error:0200100D:system library:fopen:Permission denied 2018-09-02T12:46:07.191+0000 F CONTROL [main] Failed global initialization: InvalidSSLConfiguration: Can not set up PEM key file. 2018-09-02T12:46:08.138+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2018-09-02T12:46:08.140+0000 E NETWORK [main] cannot read certificate file: /etc/ssl/mongo.pem error:0200100D:system library:fopen:Permission denied 2018-09-02T12:46:08.140+0000 F CONTROL [main] Failed global initialization: InvalidSSLConfiguration: Can not set up PEM key file. 2018-09-02T12:46:09.498+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2018-09-02T12:46:09.500+0000 E NETWORK [main] cannot read certificate file: /etc/ssl/mongo.pem error:0200100D:system library:fopen:Permission denied 2018-09-02T12:46:09.500+0000 F CONTROL [main] Failed global initialization: InvalidSSLConfiguration: Can not set up PEM key file.
What i doing wrong?
https://ask.fedoraproject.org/en/question/67927/how-to-understand-an-selinux-file-permission-denied-issue/
That's the exact error code, seems to be SELinux related.
If you have further questions you should ask the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
I have the same problem, have not solved yet.