1

I have the following docker compose:

services:
  run_program:
    image: image:1
    entrypoint: python main.py
    environment:
      - HOME=/home
    volumes:
      - $HOME/.aws:/home/.aws:ro

This should allow me to access host ~/.aws/credentials inside docker. However boto3 is spitting this error:

botocore.exceptions.ProfileNotFound: The config profile (default) could not be found

When I open an interactive docker session on that image like so:

docker run -e "HOME=/home" -v $HOME/.aws:/home/.aws -it --entrypoint bash image:1

And I check what is inside /home/.aws I see a credentials file there. But when I try to do cat /home/.aws/credentials to check the contents I get:

cat: /home/.aws/credentials: Is a directory

And the directory is empty. According to all tutorials and documentations this should work. All files inside host ~/.aws have read permissions and ~/.aws/credentials on host have the default profile set up.

If it makes any difference my host machine is a Mac, and docker daemon is provided by minikube.

UPDATE:

After some more digging I see I should first mount the host directory in minikube VMlike this:

minikube mount ~/.aws/:/host/.aws

but trying this gives the following error:

Exiting due to GUEST_MOUNT: mount with cmd /bin/bash -c "sudo mount -t 9p -o dfltgid=$(grep ^docker: /etc/group | cut -d: -f3),dfltuid=$(id -u docker),msize=262144,port=55424,trans=tcp,version=9p2000.L 192.168.64.1 /host/.aws" : /bin/bash -c "sudo mount -t 9p -o dfltgid=$(grep ^docker: /etc/group | cut -d: -f3),dfltuid=$(id -u docker),msize=262144,port=55424,trans=tcp,version=9p2000.L 192.168.64.1 /host/.aws": Process exited with status 32
stdout:

stderr:
mount: /host/.aws: mount(2) system call failed: Connection refused.

And this seems to be related to this issue however I haven't figured it out how to solve this on a Mac yet.

Amuoeba
  • 624
  • 9
  • 28
  • Do you know which minikube driver you're using? It looks like the [filesystem mount paths](https://minikube.sigs.k8s.io/docs/handbook/mount/) could be different depending on the driver. – David Maze Jan 09 '23 at 19:20
  • I am using hyperkit. And yes after some more digging I see I need to mount in minikube first and then in docker . But I am getting mount(2) system call failed: Connection refused. Error when I try to mount in minikube VM. Will eddit question to include this. – Amuoeba Jan 09 '23 at 19:30
  • 1
    There is a typo in `$HOME/.aws:/home/.aws:ro`, should be something like `$HOME/.aws:/home/ubuntu/.aws:ro` – Philippe Jan 09 '23 at 19:41
  • Same as https://stackoverflow.com/questions/67521601/botocore-exceptions-profilenotfound-pass-aws-credentials-to-docker-image ? – Coin Graham Jan 10 '23 at 16:31
  • Not really, the issue is generalised for mounting any host directory to a docker container running behind minikube. I can't mount any host directory. – Amuoeba Jan 11 '23 at 08:38
  • Currently I will bypass this issue by providing credentials as env variables, but will circle back to this mounting problem and I hope I find what the problem is. – Amuoeba Jan 11 '23 at 08:40

0 Answers0