Solve the problem of docker log mounting

Solve the problem of docker log mounting

The key is that the local server does not have write permissions

The key is here (Permission denied). I haven't looked at the positive side. I thought there was a problem with the configuration log file. The following are some exceptions

10:35:09,498 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - openFile(null,true) call failed. java.io.FileNotFoundException: logs/bandwidth.log.2019-04-25.log (Permission denied)
    at java.io.FileNotFoundException: logs/bandwidth.log.2019-04-25.log (Permission denied)
    at at java.io.FileOutputStream.open0(Native Method)
    at at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:26)
    at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:204)
    at ch.qos.logback.core.FileAppender.start(FileAppender.java:127)
    at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:100)
    at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:90)
    at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
    at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)

I tried it many times before I really understood the reason. It was also inspired by something I saw on the Internet. I hope everyone can also notice that I used the following command to solve it perfectly.

docker run -it --privileged=true -v /dockerlogs:/app/logs -d -p 5080:5080 82edb4bbc79b

After mounting an existing directory on the host, "Permission denied" is reported when operating it in the container

This can be solved in two ways:

1> Turn off selinux.

Temporary shutdown: # setenforce 0

Permanently disable: Modify the /etc/sysconfig/selinux file and set the value of SELINUX to disabled.

2> Start the container in privileged mode

Specifying the --privileged parameter

like:

# docker run -it --privileged=true -v /test:/softlogs

Additional knowledge: docker -v mounts logs to the host

Today I used Docker to pull a vsftp image and ran it. I wanted to mount the logs of this container to the host machine for easy viewing. As a result, the logs did not come out. I searched Baidu for a long time but could not find the reason.

Finally, it was discovered that it was necessary to first create a new file with the same name as the log in the mount directory of the host machine, as follows.

The above is the location of my container log

1. At the beginning, I ran the container and mounted the logs like this (normally, it can be mounted, but this is not normal~~~), but the logs did not come out.

docker run -d -v /home/ftp:/home/vsftpd -p 20:20 -p 21:21 -p 21100-21110:21100-21110 -v /home/logs/:/var/log/vsftpd/ -e FTP_USER=cqs -e FTP_PASS=chaoshiye@2020 --name vsftpd fauria/vsftpd

2. The actual solution is to create the file vsftpd.log in the host mount directory, and then execute the above mount, it will be successful.

The above article on solving the problem of docker log mounting is all the content that the editor shares with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Docker View the Mount Directory Operation of the Container
  • Solve the problem of failure to mount files or directories using ./ relative path in docker run
  • Implementation of mounting NFS shared directory in Docker container
  • Docker - Summary of 3 ways to modify container mount directories
  • Docker mounts local directories and data volume container operations
  • Docker starts the elasticsearch image and solves the error after mounting the directory
  • Solve the problem that the directory mounted by docker cannot be read and written

<<:  HTML Tutorial: Ordered Lists

>>:  MySQL 8.0.22 zip compressed package version (free installation) download, installation and configuration steps detailed

Recommend

Complete steps to use element in vue3.0

Preface: Use the element framework in vue3.0, bec...

Detailed installation and use of virtuoso database under Linux system

I've been researching some things about linke...

Usage instructions for the docker create command

The docker create command can create a container ...

Using zabbix to monitor the ogg process (Linux platform)

The ogg process of a database produced some time ...

12 Javascript table controls (DataGrid) are sorted out

When the DataSource property of a DataGrid control...

JavaScript basics of this pointing

Table of contents this Method In the object Hidde...

Detailed explanation of mysql backup and recovery

Preface: The previous articles introduced the usa...

js, css, html determine the various versions of the browser

Use regular expressions to determine the IE browse...

Native js encapsulation seamless carousel function

Native js encapsulated seamless carousel plug-in,...

Example of converting spark rdd to dataframe and writing it into mysql

Dataframe is a new API introduced in Spark 1.3.0,...

MySQL database introduction: detailed explanation of database backup operation

Table of contents 1. Single database backup 2. Co...

How to run Linux commands in the background

Normally, when you run a command in the terminal,...

HTML thead tag definition and usage detailed introduction

Copy code The code is as follows: <thead> &...

Nginx reverse proxy configuration to remove prefix case tutorial

When using nginx as a reverse proxy, you can simp...