Volume not mounting properly when running shell inside a container - docker

I want to encrypt my Kubernetes file to integrate it with Travis CI and for that, I am installing Travis CI CLI via docker container. When the container runs and I mount my current working directory to /app It just creates an empty folder.
I have added the folder in shared folders as well in the Virtual Box but nothing seems to work. I am using Docker Toolbox on Windows 10 home.
docker run -it -v ${pwd}:/app ruby:2.3 sh
It creates the empty app folder along with the other folders in the container but does not mount the volumes.
I also tried using
docker run -it -v //c/complex:/app ruby:2.3 sh
as someone suggested to use the name you specify in the Virtual Box.

Docker run -it -v full path of current directory:/app ruby:2

Related

Mounted Docker Volumes Are Empty

Problem
The $(pwd)/app directory locally contains many subdirectories and files. So does the directory in my Docker image /usr/local/app. When I run the following
docker run -it --rm -v $(pwd)/app:/usr/local/app my_image bash
the command is successful, but the /usr/local/app directory is now empty. It seems that I've mounted something to this location, but it's empty.
Is there something that I'm missing here that I should be aware of?
Context
This exact command used to succeed. The only recent change is that I uninstalled Docker Desktop in favor of just using the Docker Engine running on a local minikube instance. I'm using Docker version 20.10.22, build 3a2c30b63a on MacOS Ventura.

Docker bind mount directory in /tmp not working

I'm trying to mount a directory in /tmp to a directory in a container, namely /test. To do this, I've run:
docker run --rm -it -v /tmp/tmpl42ydir5/:/test alpine:latest ls /test
I expect to see a few files when I do this, but instead I see nothing at all.
I tried moving the folder into my home directory and running again:
docker run --rm -it -v /home/theolodus/tmpl42ydir5/:/test alpine:latest ls /test
at which point I see the expected output. This makes me thing I have mis-configured something and/or the permissions have bitten me. Have I missed a step in installing docker? I did it via sudo snap install docker, and then configured docker to let me run as non-root by adding myself to the docker group. Running as root doesn't help...
Host machine is Ubuntu 20.04, docker version is 19.03.11
When running docker as a snap...
all files that Docker uses, such as dockerfiles, to be in $HOME.
Ref: https://snapcraft.io/docker
The /tmp filesystem simply isn't accessible to the docker engine when it's running within the snap isolation. You can install docker directly on Ubuntu from the upstream Docker repositories for a more traditional behavior.

docker bind mounting not work with "not home" folder

I'm tring to play with bind mounting and i encourred in a strange behavior, i understand that bind mounting mount a host's folder in the container file system obscuring the original container content. Now when i try to do for examle:
docker run -it -v /home/user:/tmp ubuntu bash
in the /tmp folder of contaner there is the user's home but when i try to bind a "not home folder" like /var/lib:
docker run -it -v /var/lib:/tmp ubuntu bash
the /tmp folder inside a container is empty, why this appen?
Moreover if i do inside at the last container for example "touch foo" and i run another container with the same binding:
docker run -it -v /var/lib:/tmp ubuntu bash
I'll find the foo file inside /tmp folder
additional info: i run a ubuntu 19 server inside a VMaware virtual machine
i found a "dirty" solution, i had previoussly installed docker via snap, i reinstalled docker via apt and now work fine, this will remain a minstery

Not able to mount -v in the run command

I am new to the concept of Docker. In my office server we have installed Docker and running the Jenkins images as containers.
We want to run the below command in the Jenkinsfile in a process to create the Jenkins pipeline.
docker run --rm -p 8080:8080 -v $PWD/app:/opt/app --name=app-server App
The problem is face is the volumes are not mounting in the /opt/app from the $PWD/app (which is the volume of the Jenkins container).
I have app.txt file in the $PWD/app. After running the above command it should present in the /opt/app, but the folder is empty.
Because of this the configuration files are missing in the app-server container volume. Error config files are missing is happening.
What is the reason for this problem. Why the files in the $PWD/app are not mounting to the /opt/app folder?
Point to consider:
docker run command is running in the Jenkins container.
The command on top is running prefect when the jenkins is running locally,not as docker container.

using local folder into docker container

Hi I have a windows machine and I installed a docker desktop on it and created a ubuntu container on it.
In docker settings I checked my C: Drive under shared drive option. and I created a folder under /opt named /mydata in this container
Now I run this command:
docker my_container_name run -v /Users/john/Documents/DOCKER_FOLDER:/opt/mydata
But I don't see the files under DOCKER_FOLDER to be in /opt/mydata folder.
Not sure what I a doing wrong.
the right command is:
docker my_container_name run -v c:/Users/john/Documents/DOCKER_FOLDER:/opt/mydata ls /opt/mydata
so you need to specify the volume letter and a command to run

Resources