How to mount volume from host to container

Edward

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.

enter image description here

I could access http://localhost:8081/, but the log file did not create under D:\Test.

Old Schooled

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to mount volume from container to host in Docker?

How does volume mount from container to host and vice versa work?

how to mount host directory to container VOLUME?

How to mount volume from my container in kubenetes

How is docker able to mount a volume from docker client into a docker container running on docker host?

Mount volume from host in Dockerfile long format

Docker / Windows Container: how to mount a host folder as data volume on Windows 2016

How to mount the volume of host to docker container with executable file permission using docker api

LXC: How do I mount a folder from the host to the container?

How to find volume files from host while inside docker container?

Mount a local directory as volume in container, from the Dockerfile

How to add volume mount to running postgreSQL container?

mount EBS volume from one host to totally different host

Mount volume to host

"Mount" a Docker buildx builder from host to container

Replace a file from host to container with mounted volume

Share directory or volume with container from host

Volume mount one file or directory straight from Container A to Container B

How to mount a directory in a Docker container to the host?

How to mount a directory in the docker container to the host?

How to mount host codes to container in docker?

How to mount a host directory into a running docker container

Azure Container Instances - how to mount volume from Azure File Share through the Azure Portal?

Is it possible to mount the host path or docker volume to the path in the image from dockerfile?

Mount host directory into a docker container run from within docker container

How do I mount a host directory as a volume in docker compose

How do I mount a Docker volume while using a Windows host?

can I mount a file from volume in docker to the container?

Dockerfile VOLUME does not mount host