How do i download files from a minio s3 bucket using curl - jenkins

I am trying to download contents of a folder from a minio s3 bucket.
i am using the following command.
I am able to download a specific file using
# aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model/requirements.txt .
But the below throws an error if it try to download all the contents of the folder
# aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model/* .
fatal error: An error occurred (404) when calling the HeadObject operation: Key "3/050d4b07b6334997b214713201e41012/artifacts/model/*" does not exist
Any help will be appreciated

I was finally able to get it by running
aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model . --recursive
The one problem i ran into was i had to use the aws-cli using pip install as that's the only way i could the --recursive option to work.

You could also use the minio client and set an alias on minio command. Here is an example taken from the official documentation showing how to achieve this using the docker version of minio client:
docker pull minio/mc:edge
docker run -it --entrypoint=/bin/sh minio/mc
mc alias set <ALIAS> <YOUR-S3-ENDPOINT> [YOUR-ACCESS-KEY] [YOUR-SECRET-KEY] [--api API-SIGNATURE]
You can instead install the client on any OS.
Once done, to copy content from s3 you would only have to do this:
{minio_alias} cp {minio_s3_source} {destination}

Related

How to open the internal Docker URL using an external web page?

I'm trying to reproduce the code from this github:enter link description here. The purpose of this project is to use the GPU to perform some similarity search. Based on the instruction of the README file, I can now open the search server website inside the docker now. But I have tried many ways to try to open this server URL from an external browser, but all failed, can anyone help? Thanks!
Here is how I opened my server URL inside the Docker:
Download Docker Desktop.
Pull the images:
docker pull klorton/gpusimilarity:latest
From the docker directory(The docker file is inside the github), build:
docker build -t gpusim:internal .
Build a fingerprint file (Database), change PATH/TO/SMIGZ_DIR to your own path to the smi.gz file, change INPUT to your own smi.gz file.
docker run -v /PATH/TO/SMIGZ_DIR:/data -it gpusim python3 \
/gpusimilarity/bld/python/gpusim_createdb.py /data/INPUT.smi.gz \
/data/OUTPUT.fsim
Start a gpusimilarity server interactively, change /path/to/fsim/files to your own path to the fsim file.
docker run --net=host -v /path/to/fsim/files:/mnt/fsim -it \
klorton/gpusimilarity:latest python3 /gpusimilarity/bld/python/gpusim_server.py \
/mnt/fsim/OUTPUT.fsim --port 8080 --http_interface
The server will say "Ready for search" at this moment. Something like this:
enter image description here
7.The server is running now. In the README file, the author said that we can just use the following link: http://localhost:8080 to open it. But I failed by doing this.
Then I tried to open the URL inside the Docker, install w3m first.
apt-get install -y w3m
Open the URL inside the Docker:
w3m http://localhost:8080
It shows like this:
enter image description here
Can someone tell me how to open this URL outside of Docker? Thanks a lot!
I have tried many of the methods available on Google, But most of them don't work...
I solved this. Just Downgrade docker and run the same process by linux.

can't connect to google cloud using airflow 2.0 in docker with json key file

I am trying to setup a GCP connection with apache airflow 2.0 in docker from MAC OS using JSON key file, I got this error when I trigger the DAG:
ERROR - [Errno 2] No such file or directory:
'/Users/my_user/PycharmProjects/airflow_docker/plugins/key.json'
is there some configuration I need to set up in docker?
Check if the file key.json is really located at that place because it seems it isn't. You can do that by "debugging" your docker image like this:
docker run -it --rm --entrypoint sh <name-of-image>
this command allows you to access the image through the shell. That way you'll be able to see if the file is really located in that path. Do some ls operations in that path and others to locate where the key.json file really is
The most likely issue is that it's missing the volume mapping in your docker-compose.yaml
volumes:
...
- /Users/my_user/PycharmProjects/airflow_docker/plugins/:/opt/airflow/plugins

boto3: config profile could not be found

I'm testing my lambda function wrapped in a docker image and provided environment variable AWS_PROFILE=my-profile for the lambda function. However, I got an error : "The config profile (my-profile) could not be found" while this information is there in ~/.aws/credentials and ~/.aws/config files. Below are my commands:
docker run -e BUCKET_NAME=my-bucket -e AWS_PROFILE=my-profile-p 9000:8080 <image>:latest lambda_func.handler
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '"body":{"x":5, "y":6}}'
The thing is that if I just run the lambda function as a separated python script then it works.
Can someone show me what went wrong here?
Thanks
When AWS is showing how to use their containers, such as for local AWS Glue, they share the ~/.aws/ in read-only mode with the container using volume option:
-v ~/.aws:/root/.aws:ro
Thus if you wish to follow AWS example, your docker command could be:
docker run -e BUCKET_NAME=my-bucket -e AWS_PROFILE=my-profile-p 9000:8080 -v ~/.aws:/root/.aws:ro <image>:latest lambda_func.handler
The other way is to pass the AWS credentials using docker environment variables, which you already are trying.
You need to set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
Your home directory (~) is not copied to Docker container, so AWS_PROFILE will not work.
See here for an example: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html

How to access docker volumes on a Synology NAS

I am trying to get a Matrix Synapse server running on my Synology NAS through docker.
When I run the generate command to get the intial homeserver.yaml, it does get generated :
$ sudo docker run -it --rm --mount type=volume,src=synapse-config,dst=/data -e SYNAPSE_SERVER_NAME=my.matrix.host -e SYNAPSE_REPORT_STATS=yes matrixdotorg/synapse:latest generate
Creating log config /data/my.matrix.host.log.config
Generating config file /data/homeserver.yaml
Generating signing key file /data/my.matrix.host.signing.key
A config file has been generated in '/data/homeserver.yaml' for server name 'my.matrix.host'. Please review this file and customise it to your needs.
So the file is generated in /volume1/#docker/volumes/synapse-config/_data but when I try to navigate there I get a permission denied error. I am ssh-ing using my admin account on the Synology.
How can I access this file through ssh CLI or DSM web interface or something else ?
Try switching to root temporarily with sudo -i
When you are done, type exit to revert back to admin status.

use gcsfuse to mount google cloud storage buckets in a docker container

I am trying to mount a google cloud bucket from within a docker container and get the following error:
[root#cdbdc9ccee5b workdir]# gcsfuse -o allow_other --debug_gcs --key-file=/src/gcloud_service_account.json my-bucket-name /gcloud
Using mount point: /gcloud
Opening GCS connection...
Opening bucket...
daemonize.Run: readFromProcess: sub-process: mountWithArgs: mountWithConn: setUpBucket: OpenBucket: Bad credentials for bucket "my-bucket". Check the bucket name and your credentials.
My credentials work on my host machine, but not on the running container. The API says not to use root to connect, but you can override that with the -o allow_other flag (fuse flag). Any ideas are appreciated.
This is running on a centos7 base image
Root versus not is a red herring here; the credentials in question are GCS credentials.
See here for documentation on handing GCS credentials to gcsfuse. The easiest way to do this is with the credentials you configured your GCE VM with originally (assuming you're running on GCE), which is what makes running gcsfuse work without any further effort usually. But if that doesn't work, you can use the flag --key-file to give gcsfuse a path to a JSON key file you download from the Google Developers Console.
Update: I was able to get gcsfuse to mount. I had to run docker with the --priviledged option. (thanks #thaJeztah for the breadcrumb!)
You really want to avoid running containers using the --privileged option.
I believe you only need to add the SYS_ADMIN capability and access to the /dev/fuse device.
docker run \
--rm -it \
--cap-add SYS_ADMIN \
--device /dev/fuse \
ubuntu

Resources