Unable to write/modify/create in the mounted folder via docker container
docker run -it --rm -v ${pwd}:/files ubuntu /bin/bash
when the docker is running in interactive mode
Change directory to files
cd files
Now try to write /create directory in mounted folder ('files')
mkdir test
you get ERROR :
mkdir: cannot create directory 'ff': Permission denied
How to overcome that error:??
Related
Dockerfile
FROM centos
RUN mkdir /test
#its ensured that sample.sh exists where the dockerFile exists & being run
COPY ./sample.sh /test
CMD ["sh", "/test/sample.sh"]
Docker run cmd:
docker run -d -p 8081:8080 --name Test -v /home/Docker/Container_File_System:/test test:v1
Log output :
sh: /test/sample.sh: No such file or directory
There are 2 problems here.
The output says sh: /test/sample.sh: No such file or directory
as I have mapped a host folder to container folder, I was expecting the test folder & the sample.sh to be available at /home/Docker/Container_File_System post run, which did not happen
Any help is appreciated.
When you map a folder from the host to the container, the host files become available in the container. This means that if your host has file a.txt and the container has b.txt, when you run the container the file a.txt becomes available in the container and the file b.txt is no longer visible or accessible.
Additionally file b.txt is not available in the host at anytime.
In your case, since your host does not have sample.sh, the moment you mount the directory, sample.sh is no longer available in the container (which causes the error).
What you want to do is copy the sample.sh file to the correct directory in the host and then start the container.
The problem is in volume mapping. If I create a volume and map it subsequently it works fine, but directly mapping host folder to container folder does not work.
Below worked fine
docker volume create my-vol
docker run -d -p 8081:8080 --name Test -v my-vol:/test test:v1
I'm running a long docker command
docker exec -t -i 9f5865473027 cloudgene run imputationserver#1.4.1 --files /illumina/runs/con/chrX_impute/ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz --refpanel apps#1000g-phase-3-v5#2.0.0 --conf /etc/hadoop/conf --population AFR --mode qconly --output /illumina/runs/con/chrX_impute
but this is giving an error
Error: Input Files (VCF): file '/illumina/runs/con/chrX_impute/ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz' not found.
why isn't docker finding a file that is given with an absolute path (even with a relative path)? How can I make docker find this file?
even when I do
docker exec -it 9f5865473027 ls /illumina/runs/con/chrX_impute/ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz
I still get ls: cannot access /illumina/runs/con/chrX_impute/ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz: No such file or directory
when I do docker exec -it 9f5865473027 ls . it seems to be in / or the absolute top directory, but using this information and entering the file name without / thus docker exec -it 9f5865473027 ls illumina/runs/con/chrX_impute/ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz
Docker is still unable to find the file :(
I can see higher directories via docker's ls but the directory that I'm in is docker exec -it 9f5865473027 ls illumina/runs/con/chrX_impute mysteriously shows as empty (which it isn't)
The solution to this problem is to copy the file to the container. Each "container" seems to act as if it is a separate computer.
All I had to do is
docker cp ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz 9f5865473027:/illumina/runs/con/chrX_impute/
and then the file shows up as
docker exec -it 9f5865473027 ls illumina/runs/con/chrX_impute
ALL.chrX.PAR2.phase3_v5.shapeit2_mvncall_integrated.noSingleton.genotypes.vcf.gz
I have used simple command to create nginx container with latest image.
docker run -d -p 8080:80 -v ~/myhtmlfoler:/usr/share/nginx/html nginx
Observations:
1) myhtmlfolder which is my source folder on linux (RHEL ATOMIC) host have index.html. confirmed.
2) when docker exec with cd command to /usr/share/nginx/html (or /bin/bash) i can not ls to this folder and it says permission denied. can not make any file or directory at this location. sudo not running too inside
3) at host i have root access and folder and file have 777 rights...
continuously getting 403 forbidden
I am trying to mount my VM Machine folder to Container using below command
sudo docker run -d -it --name devtest \
-v /home/minhaj/GOQTINDOOR:/home/user:Z therecipe/qt:linux bash
But do not see any folder on my Container home/user. Please advise what is wrong in my command or do I need to execute more commands to mount folder on Container.
Your issue is that you are running the container in detached mode. Remove -d
sudo docker run -it --name devtest -v /home/minhaj/GOQTINDOOR:/home/user therecipe/qt:linux bash​
After this if you compile something inside the container and copy it is inside the /home/user folder it will be automatically available inside /home/minhaj/GOQTINDOOR. You can copy and delete any file inside /home/minhaj/GOQTINDOOR. But you can't delete the /home/minhaj/GOQTINDOOR folder itself as it the mount point.
Any files or folder inside /home/minhaj/GOQTINDOOR can be deleted from inside the container by delete them from /home/user folder.
docker cp command is only required if you want to copy a file which is not there in any mounted path.
For that you can use
docker cp <containerid>:<pathinsidecontainer> <pathonhost>
I try to copy the content of a folder (on my server) to my container:
docker cp sonatype-work-backup/* nexus:/sonatype-work/
So I want the content of sonatype-work in my /sonatype-work/ of nexus. But it doesn't work with the * and without the star it's copying the directory sonatype-work-backup inside my sonatype-work directory. I can't perform mv after that.
you could just mount that directory in your container at run
docker run -v /sonatype-work-backup:/mnt --name nexus nexus-image
then
docker exec -it nexus bash
and just cp from /mnt to your desired folder