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

Summary of MySql index, lock, and transaction knowledge points

This article summarizes the knowledge points of M...

Detailed explanation of Linux text processing tools

1. Count the number of users whose default shell ...

Detailed steps to install MySQL on CentOS 7

In CentOS7, when we install MySQL, MariaDB will b...

Designing the experience: What’s on the button

<br />Recently, UCDChina wrote a series of a...

Native JS to implement paging click control

This is an interview question, which requires the...

WeChat applet realizes multi-line text scrolling effect

This article example shares the specific code for...

How to construct a table index in MySQL

Table of contents Supports multiple types of filt...

Axios cancel request and avoid duplicate requests

Table of contents origin status quo Cancel reques...

A simple way to build a Docker environment

First, let’s understand what Docker is? Docker is...

MySQL 5.7.20 installation and configuration method graphic tutorial (win10)

This article shares the installation and configur...

Provides helpful suggestions for improving website design

<br />Scientifically Design Your Website: 23...

Analyze how uniapp dynamically obtains the interface domain name

background The interface domain name is not hard-...

VMware vSphere 6.7 (ESXI 6.7) graphic installation steps

Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...