Home > Operation and Maintenance > Docker > What to do if docker v doesn't work

What to do if docker v doesn't work

藏色散人
Release: 2021-12-09 15:02:46
Original
4388 people have browsed it

Solutions for docker v not working: 1. Add privileges to the container when running the container; 2. Temporarily turn off selinux; 3. Add selinux rules and add the directory to be mounted to the whitelist.

What to do if docker v doesn't work

The operating environment of this article: ubuntu 18.04 system, Docker version 20.10.11, Dell G3 computer.

What should I do if docker v does not work?

About the problem that the service cannot be started after docker -v is mounted

I am learning docker recently and made a simple nginx image.
Due to the need to make a playable nginx. Therefore, the configuration files in the container need to be mounted on the host for easy operation.
After working on it for a while, I found that docker run added the -v attribute. The service will not start.

I have been troubled for a while and took a look at mounting this thing.
Finally found the cause of the problem, record it here. The reason is that the security module selinux in CentOS7 disables permissions. There are at least the following three ways to solve the problem of the mounted directory not having permissions:

1. When running the container, Add privileges to the container:

Example: docker run -i -t –privileged=true -v /home/docs:/src waterchestnut/nodejs:0.12.0

2, temporarily close selinux:

Example: su -c

Execute afterwards:

docker run -i -t -v /home/docs:/src waterchestnut/nodejs:0.12.0
Copy after login
Copy after login

Note: Remember to re-enable selinux later, command: su -c "setenforce 1 ”

3, add selinux rules and add the directory to be mounted to the whitelist:

Example: chcon -Rt svirt_sandbox_file_t /home/docs

Execute after:

docker run -i -t -v /home/docs:/src waterchestnut/nodejs:0.12.0
Copy after login
Copy after login

After you have the mounting permission, you can start successfully.

Recommended learning: "Docker Video Tutorial"

The above is the detailed content of What to do if docker v doesn't work. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template