Unable to iterate through a specific folder - docker

docker exec -it retail_pg ls -ltr /Users/fallout/research/data/retail_db_json
The command above should display the folder within the retail_db_json. But it is giving me a total count of 0. I cannot understand why when it is able to iterate properly over data and research directory. Why is not working for retail_db_json? Is there something off with the command ?

Related

ubvnc docker container can't update path via shell script

I have made a ubuntu vnc following this question:
Build a full Ubuntu desktop docker image
and then I connected to it by running docker exec -it ubvnc sh. I want to add a folder containing some of my programs to the path, namely myprogs, so I tried adding to my .bashrc file, however that didn't work, so I tried making a script which I could run after connecting that would update my path, but this script is also not updating my path as you can see below:
# whoami
root
# pwd
/root
# ls -ltr myprogs
total 0
-rw-r--r-- 1 root root 0 Jul 5 02:23 someScript.sh
# cat fixPath.sh
export PATH="/root/myprogs:$PATH"
# ./fixPath.sh
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# export PATH="/root/myprogs:$PATH"
# echo $PATH
/root/myprogs:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#
As you can see in the above, one would expect the path to be updated by running ./fixPath.sh however this doesn't work. I am able however to update the path by running the content of fixpath.sh by pasting it into the terminal and pressing enter (again, as can be seen above). I'd like to know why this is the case and if possible, how to make it so I can update my path by running such a script, or even better, via .bashrc.

How to get files generated by docker run to host

I have run docker run to generate a file
sudo docker run -i --mount type=bind,src=/home/mathed/Simulation/custom_desman/1/Strains/Simulation2/Assembly,target=/home/mathed/Simulation/custom_desman/1/Strains/Simulation2/Assembly 990210oliver/mycc.docker:v1 MyCC.py /home/mathed/Simulation/custom_desman/1/Strains/Simulation2/Assembly/final_contigs_c10K.fa
This is the message I've got after executing.
20181029_0753
4mer
1_rename.py /home/mathed/Simulation/custom_desman/1/Strains/Simulation2/Assembly/final_contigs_c10K.fa 1000
Seqs >= 1000 : 32551
Minimum contig lengh for first stage clustering: 1236
run Prodigal.
/opt/prodigal.linux -i My.fa -a gene.aa -d gene.nuc -f gbk -o output -s potential_genes.txt
run fetchMG.
run UCLUST.
Get Feature.
2_GetFeatures_4mer.py for fisrt stage clustering
2_GetFeatures_4mer.py for second stage clustering
3_GetMatrix.py 1236 for fisrt stage clustering
22896 contigs entering first stage clustering
Clustering...
1_bhsne.py 20
2_ap.py /opt/ap 500 0
Cluster Correction.
to Split and Merge.
1_ClusterCorrection_Split.py 40 2
2_ClusterCorrection_Merge.py 40
Get contig by cluster.
20181029_0811
I now want to get the files generated by MyCC.py to host.
After reading Copying files from Docker container to host, I tried,
sudo docker cp 642ef90103be:/opt /home/mathed/data
But I got an error message
mkdir /home/mathed/data/opt: permission denied
Is there a way to get the files generated to a directory /home/mathed/data?
Thank you.
I assume your dest path does not exist.
Docker cp doc stats that in that case :
SRC_PATH specifies a directory
DEST_PATH does not exist
DEST_PATH is created as a directory and the contents of the source directory are copied into this directory
Thus it is trying to create a directory fro DEST_PATH... and docker must have the rights to do so.
According to the owner of the DEST_PATH top existing directory, you may have to either
create the directory first so that it will not be created by docker and give it the correct rights (looks like it has no rights to do so) using sudo chown {user}:{folder} + chmod +x {folder}
change the rights to the parent existing directory (chown + chmod again),
switch to path where docker is allowed to write.

when using docker run i get mv: cannot stat but it works if i use /bin/bash

I need to move some files around and when i use the following command i get a connot stat error of move
docker run -v D:/PKS/potree/test/dist:/data1 -v D:/PKS/potree/test/tiles:/data2 -v D:/PKS/potree/test/tmp:/data3 oscar/mpc:v1 mv /data1/execution4/*/* /data1/tmp2
mv: cannot stat '/data1/execution4/*/*': No such file or directory
if i instead run a /bin/bash and manually type the same mv /data1/execution4/*/* /data1/tmp2 it works.
How can this be?
The shell expands your wildcards (or doesn’t, because they match nothing) before ever running docker. You’ll have to tell Docker to run a shell if you want wildcards expanded inside the container.
Thanks to Davis to put my in the right direction.
The answer is to do as following instead:
docker run oscar/mpc:v1 /bin/bash -c "mv /data1/execution22/*/* /data1/out1/"

Copy a directory from container to host

I have saved a folder called "ec2-user" in an image. And I can easily extract one of the files...
docker run -it shantanuo/bkup sh
docker exec -it e7611fc860a6 sh -c " cat /tmp/ec2-user/t1.txt" > t1.txt
This works as expected. But I do not know how to copy the entire directory "ec2-user" that is around 8 GB
In other words I am using docker as backup device. This is different that application deployment, but I will like to know if this is OK.
Looking at the name of your file and its size (8GB) I guess you're doing a database backup?
Since you want to copy the entire directory and it is relatively big, why not consider compressing the backup directory to a single file and then just do
docker cp my_container:/tmp/bkup/abc.xz .
To compress your backup you can use the xz utility.
Example:
shantanuo/bkup | xz -8 > /tmp/bkup.xz

Access is denied while docker save

I am trying to save a docker image in windows so that I can load to another Linux box,in between while saving the images in windows, I got an error stating access is denied to rename the docker temp file.
I checked the permission everything looks fine, in fact I can able to edit. Any help here is highly appreciable. I am using docker 1.11.0
docker save -o . <imgID>
rename .docker_temp_742575903 .: Access is denied.
Never mind, along with path I need to give my new file name that docker wanted to create and it don't happen implicitly, in my cases I gave
docker save -o ./<tar name that you wanted docker to create> <imgID>
For the similar issue but on unix:
root#linux:/opt/docker# docker save -o ./presto.tar starburstdata/presto
open .docker_temp_359214587: permission denied
You can use different syntax to save the image as a workaround:
root#linux:/opt/docker# docker save starburstdata/presto > presto.tar
root#linux:/opt/docker# ls -l
razem 1356196
-rw-r--r-- 1 root root 1388737024 maj 23 11:16 presto.tar
I workaround the problem on linux by changing the current forlder permission to 777. Make sure your current direct :
mkdir ~/docker-images
cd ~/docker-images
chmod 777 ./
sudo docker save <img_id> -o ./<filename>
You are not giving image name and it's creating some temp name by default but, while renaming that it's throwing error. you can use this command to solve this problem.
docker save -o <some custom name with path> <imgID or REPOSITORY:TAG>
something like this if you want to create in present directory
docker save -o ./ubuntu_image.tar ubuntu:latest
or
docker save -o ./ubuntu_image.tar eat546t
If you want to create in specific location
docker save -o path/of/image/ubuntu_image.tar ubuntu:latest

Resources