How to add a certificate to docker

How to add a certificate to docker

1. Upgrade process: sudo apt-get update

Problems such as missing packages and old package versions can be solved in this way. If not, then it means that authentication is missing and you need to generate your own authentication certificate.

2. Generate your own authentication certificate

Create a folder first

mkdir -p certs

After that, create the certificate. The certificate is generated in the folder just created.

openssl req -newkey rsa:4096 -nodes -sha256 -keyout /root/certs/domain.key -x509 -days 365 -out /root/certs/domain.crt

Then put the certificate generated by certs in the /etc/docker/ directory

Then restart the docker service sudo service docker restart

After reboot

Supplement: Configure HTTPS certificate using nginx installed with Docker

Create a new ssl.conf and put the file in the conf.d folder

server {
  listen 443;
  server_name localhost;
  ssl on;
  root html;
  index index.html index.htm;
  ssl_certificate cert/1533224843981.pem;
  ssl_certificate_key cert/1533224843981.key;
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  location / {
   root html;
   index index.html index.htm;
  }
 }

Note: cert is a relative path. If it is a Linux folder, it is in the nginx.conf folder. If it is a Windows folder, it is in the conf folder.

run

 docker run --name mynginx -p 443:443 -v /opt/data/nginx/nginx.conf:/etc/nginx/nginx.conf
 -v /opt/data/nginx/conf.d:/etc/nginx/conf.d/default.conf 
-v /opt/data/nginx/www:/www -v /opt/data/nginx/cert:/etc/nginx/cert 
-v /opt/data/nginx/ssl.conf:/etc/nginx/conf.d/ssl.conf -d nginx

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • How to obtain a permanent free SSL certificate from Let''s Encrypt in Docker
  • Docker solution for logging in without root privileges
  • How to modify the root password of mysql in docker
  • How to change the root password in a container using Docker
  • How to obtain root permissions in a docker container
  • docker cp copy files and enter the container
  • Docker uses root to enter the container
  • Solution to the Docker container not having permission to write to the host directory

<<:  How to invert the implementation of a Bezier curve in CSS

>>:  MySQL uses frm files and ibd files to restore table data

Recommend

How to use Linux paste command

01. Command Overview The paste command will merge...

Linux command line operation Baidu cloud upload and download files

Table of contents 0. Background 1. Installation 2...

Detailed explanation of querying JSON format fields in MySQL

During the work development process, a requiremen...

What are the usages of limit in MySQL (recommended)

SELECT * FROM table name limit m,n; SELECT * FROM...

Introduction to the usage of common XHTML tags

There are many tags in XHTML, but only a few are ...

JS interview question: Can forEach jump out of the loop?

When I was asked this question, I was ignorant an...

MySQL 5.7.17 winx64 installation and configuration method graphic tutorial

Windows installation mysql-5.7.17-winx64.zip meth...

Detailed explanation of how to use $props, $attrs and $listeners in Vue

Table of contents background 1. Document Descript...

Steps to create your own YUM repository

To put it simply, the IP of the virtual machine u...

React Native JSI implements sample code for RN and native communication

Table of contents What is JSI What is different a...

HTML markup language - form

Click here to return to the 123WORDPRESS.COM HTML ...

Summary of MySQL injection bypass filtering techniques

First, let’s look at the GIF operation: Case 1: S...