Problems:After adding the -v parameter to docker run, the container will always be in the restarting state. Removing the -v parameter will allow it to run normally. Find the problem:Use docker logs 'containerId' This containerId is the containerId returned after docker run As you can see, it is a permission denied issue. Solving the problem:Add parameters when running docker: add --privileged=true For example: docker run -dit -e MYSQL_ROOT_PASSWORD=123456 --name saasdev-mysql --restart always -v /home/data/mysql:/var/lib/mysql --privileged=true -p 3308:3306 mysql:5.6 The problem was successfully solved and the container started normally A little explanation:--privileged=true With this parameter, the root in the container has real root permissions. Otherwise, the root in the container has only the permissions of an ordinary user outside. A container started with privileged can see many devices on the host and can mount them. It even allows you to start a docker container within a docker container Supplement: docker --restart=always parameter docker restarts the container automatically When you add the parameter --restart=always when creating a container, the container will automatically start when Docker is restarted. Directions:docker container update --restart=always container name The operation examples are as follows:[root@localhost mnt]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46cdfc60b7a6 nginx "nginx -g 'daemon ..." About a minute ago Up 42 seconds 80/tcp n3 79d55a734c26 nginx "nginx -g 'daemon ..." About a minute ago Up 42 seconds 80/tcp n2 f7b2206c019d nginx "nginx -g 'daemon ..." About a minute ago Up 46 seconds 80/tcp n1 [root@localhost mnt]# docker container update --restart=always n1 n1 [root@localhost mnt]# systemctl restart docker [root@localhost mnt]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46cdfc60b7a6 nginx "nginx -g 'daemon ..." 2 minutes ago Exited (0) 5 seconds ago n3 79d55a734c26 nginx "nginx -g 'daemon ..." 2 minutes ago Exited (0) 5 seconds ago n2 f7b2206c019d nginx "nginx -g 'daemon ..." 2 minutes ago Up 2 seconds 80/tcp n1 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:
|
<<: A brief discussion of the interesting box model of CSS3 box-sizing property
>>: MySQL 8.0 New Features - Introduction to Check Constraints
background I am learning nodejs recently, and I r...
MySQL paging analysis principle and efficiency im...
1. Location regular expression Let's take a l...
Virtual machines are very convenient testing soft...
Table of contents We have written about drag and ...
Server Information Management server: m01 172.16....
Experimental environment Apache and Tomcat are bo...
This article mainly introduces the relevant conte...
1. Rounded border: CSS CodeCopy content to clipbo...
Table of contents 1. Back up the old MySQL5.7 dat...
1. Enter the directory where your project war is ...
When I was writing a WeChat applet project, there...
1. Horizontal center Public code: html: <div c...
Before using jQuery to complete the fade-in and f...
Passing values between mini program pages Good ...