Docker https cannot open certificates #258

Closed
opened 2026-01-19 18:29:38 +00:00 by michael · 2 comments
Owner

Originally created by @MPolymath on GitHub.

Hello,

To launch docker and have it use https,
I am running the following command:

sudo docker run --publish 443:443 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/ --listener :8080 --tls-listener :443 --tls-cert-file /tmp/localhost.crt --force-https --tls-private-key /tmp/localhost.key

However when I access my local web server (https://localhost:443) I get the following logs:

2019/06/06 09:13:21 http: TLS handshake error from 172.17.0.1:36212: open /tmp/localhost.crt: no such file or directory

I copied the certificates in the docker container using the following command.

sudo docker cp /home/mina/transfersh/localhost.crt container_id:/tmp/
sudo docker cp /home/mina/transfersh/localhost.key container_id:/tmp/

I have also copied the certificates in the local machine in the /tmp/ directory.

This is how I created the certificates:

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Am I doing anything wrong or is the https function broken ?

Originally created by @MPolymath on GitHub. Hello, To launch docker and have it use https, I am running the following command: ``` sudo docker run --publish 443:443 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/ --listener :8080 --tls-listener :443 --tls-cert-file /tmp/localhost.crt --force-https --tls-private-key /tmp/localhost.key ``` However when I access my local web server (https://localhost:443) I get the following logs: ``` 2019/06/06 09:13:21 http: TLS handshake error from 172.17.0.1:36212: open /tmp/localhost.crt: no such file or directory ``` I copied the certificates in the docker container using the following command. ``` sudo docker cp /home/mina/transfersh/localhost.crt container_id:/tmp/ sudo docker cp /home/mina/transfersh/localhost.key container_id:/tmp/ ``` I have also copied the certificates in the local machine in the /tmp/ directory. This is how I created the certificates: ``` openssl req -x509 -out localhost.crt -keyout localhost.key \ -newkey rsa:2048 -nodes -sha256 \ -subj '/CN=localhost' -extensions EXT -config <( \ printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth") ``` Am I doing anything wrong or is the https function broken ?
Author
Owner

@dopessoa commented on GitHub:

Hello @MPolymath,

I guess the easiest way would be to mount your certificates directory inside the container, like this:

sudo docker run -v /home/mina/transfersh:/tmp/certs --publish 443:443 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/ --tls-listener :443 --tls-cert-file /tmp/certs/localhost.crt --tls-private-key /tmp/certs/localhost.key

As you're not publishing the HTTP port, both --listener and --force-https parameters shouldn't make a difference, so I removed them from the command line.

@dopessoa commented on GitHub: Hello @MPolymath, I guess the easiest way would be to mount your certificates directory inside the container, like this: `sudo docker run -v /home/mina/transfersh:/tmp/certs --publish 443:443 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/ --tls-listener :443 --tls-cert-file /tmp/certs/localhost.crt --tls-private-key /tmp/certs/localhost.key` As you're not publishing the HTTP port, both --listener and --force-https parameters shouldn't make a difference, so I removed them from the command line.
Author
Owner

@MPolymath commented on GitHub:

Thank you that is exactly what I was looking for the issue is solved.

@MPolymath commented on GitHub: Thank you that is exactly what I was looking for the issue is solved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#258