Mounted volume is empty inside container

docker-compose volumes
docker volume
docker mount host volume empty
docker bind mount=
docker-compose volume empty
mount volume
docker nfs volume
docker container empty

I've got a docker-compose.yml like this:

  image: mongo:latest
    - "27017:27017"
  image: artificial/docker-sails:stable-pm2
  command: sails lift
    - server/:/server
    - "1337:1337"
    - db

server/ is relative to the folder of the docker-compose.yml file. However when I docker exec -it CONTAINERID /bin/bash and check /server it is empty.

What am I doing wrong?

Try using:

  - ./server:/server

instead of server/ -- there are some cases where Docker doesn't like the trailing slash.

Mounted volumes are empty in the container. � Issue #25 � docker/for , Windows PowerShell Copyright (C) 2016 Microsoft Corporation. All rights reserved. PS C:\Users\bagratte> dir stitch Directory:� bagratte changed the title Mounted volumes are emty in the container. Mounted volumes are empty in the container. on Aug 5, 2016 dgageot commented on Aug 5, 2016 Hi @bagratte, thank you for taking the time to report the issue.

Aside from the answers here, it might have to do with drive sharing in Docker Setting. On Windows, I discovered that drive sharing needs to be enabled.

In case it is already enabled and you recently changed your PC's password, you need to disable drive sharing (and click "Apply") and re-enable it again (and click "Apply"). In the process, you will be prompted for your PC's new password. After this process, run your docker command (run or compose) again

Empty Folder after "docker run -v" � Issue #2979 � docker/docker , If you mount an empty directory on top of a directory that has files, you This creates in your machine /var/lib/docker/volumes/myvol/_data and� To mount an emptyDir volume in a container instance, you can deploy using an Azure Resource Manager template, a YAML file, or other programmatic methods to deploy a container group. First, populate the volumes array in the container group properties section of the file.

As per docker volumes documentation,

The host-dir can either be an absolute path or a name value. If you supply an absolute path for the host-dir, Docker bind-mounts to the path you specify. If you supply a name, Docker creates a named volume by that name

Understanding Docker volume mounts �, When the volume is empty, the ownership changes based on the mount point in the container. Once it has something in it, the ownership is fixed. So Docker behaves differently with regard to permissions: when the folder is mounted from the host vs a volume. When we enter the container, it’s the same doot directory, but we use the container’s mount namespace, which doesn’t have the mount. Hence, /doot is empty (the third command). A bind-mount created

I had similar issue when I wanted to mount a directory from command line:

docker run -tid -p 5080:80  -v /d/my_project:/var/www/html/my_project nimmis/apache-php5

The container has been started successfully but the mounted directory was empty.

The reason was that the mounted directory must be under the user's home directory. So, I created a symlink under c:\Users\<username> that mounts to my project folder d:\my_project and mounted that one:

 docker run -tid -p 5080:80  -v /c/Users/<username>/my_project/:/var/www/html/my_project nimmis/apache-php5

Mounting volume creates empty folder : docker, When I try to bind a folder from the container to the host, it always ends up in an empty folder. Both on the host and in the container. This is the … Originally, the only way to mount a bind mount to a container was to use the -v or --volume flag to specify the location of the bind mount on the host filesystem and separate the path where to mount the file or folder inside the container with a colon. The command would look like this to start a new container with a bind mount to the data

Workaround for mounting volume when the directory is non empty , I ran into this issue trying to setup a Windows container. Workaround for mounting volume when the directory is non empty for Windows Containers? If you are interested in taking the Docker Certified Associate (DCA) certification, or just� Volumes are only automatically deleted if the parent container is removed with the docker rm -v command (the -v is essential) or the --rm flag was provided to docker run. Even then, a volume will only be deleted if no other container links to it. Volumes linked to user specified host directories are never deleted by docker.

Docker volume, what I learned. For those who start working with , In conclusion, when you mount a volume into container: if volume is empty, then container will copy down it's data to the volume else volume� If you start a container with a volume that does not yet exist, Docker creates the volume for you. The following example mounts the volume myvol2 into /app/ in the container. The -v and --mount examples below produce the same result. You can’t run them both unless you remove the devtest container and the myvol2 volume after running the first one.--mount-v

Volume is empty even if there should be files, It is correctly creating the folder on my host, but it is empty and its overwriting the contents of the directory in the container, so it gets emptied as� This happens when the volume is empty and the container is created with the named volume. MacOS users now have OSXFS which handles uid/gid's automatically between the Mac host and containers. One place it doesn't help with are files from inside the embedded VM that get mounted into the container, like /var/lib/docker.sock.

  • try giving full absolute path
  • this was actually the solution to the problem, thanks :)
  • Thanks! This triggered the dialog to reenter my credentials. Now it works!
  • Holy crap, this finally solved it. I thought I was going crazy. I'd give you a bounty if I could.
  • Good addition, this can be confusing when trying to mount a directory by using a relative path into the container like this docker run -v myDir:/containerdir ... because it will silently create a docker volume (as referenced in the answer) named myDir and bind it, but it won't make the contents of myDir available in the container. In this case using the absolute path works, e.g., docker run --volume $(pwd)/myDir:/containerdir ...