I am using docker in windows 10 and want to output logs from docker container to host D:/Test
.
This is my log configuration:
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
_logger.LogError("Access Denied!!!");
return View();
}
This is my command to mount the volume
docker run -it -p 8081:80 -v D:/Test:/app/logs --name dockercoreapp10 dockercoreapp:v2
After run docker inspect dockercoreapp10
, I could see the mount.
I could access http://localhost:8081/
, but the log file did not create under D:\Test
.
What type of container are you working with?
After the run command, does the log file exist on the other side, within the container at the correct location /app/logs?
I've tried recreating your problem but using your run command, I have no problems.
(The logging stuff doesn't matter... you can put anything in the app/logs folder within your container to test it and it should appear in your mounted folder. On my side, I went into the app/logs folder and ran
touch test.txt
and test.txt appeared on the other side, no problems.)
Find the folder within the container. Put a file in there manually and check to see if it shows up on the other side. Or vice versa. My guess is that after the run command, you haven't actually placed any logs in the app/logs folder.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments