I've encountered an issue that I simply can't find any resources for online.
I'm trying to mount a directory under /tmp (e.g /tmp/testdir) on to a docker container without success, the respective directory inside the container turns out empty.
I've noticed that this issue only occurs when trying to bind mount from /tmp/, if I replicate the process from /home/, the directory in the container contains the expected files.
The host machine is an ubuntu ec2 instance:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
drwxrwxrwt 19 root root 4096 Jun 23 08:19 tmp
Here are the steps to replicate the issue:
mkdir /tmp/testdir
touch /tmp/testdir/testfile
docker run -v /tmp/testdir/:/tmp/testdir ubuntu ls /tmp/testdir
The output of the docker run command should be empty.
However if I copy /testdir outside of /tmp it works as intended:
cp -r /tmp/testdir/ ~
docker run -v /home/ubuntu/testdir/:/tmp/testdir ubuntu ls /tmp/testdir
The output of the docker run command is:
testfile
I would appreciate any insights regarding this issue. Thanks.