Reputation: 786
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.
Upvotes: 1
Views: 810
Reputation: 142
Late to the party, but just figured this out for myself. If you attempt to do a bind mount in Docker and the specified host directory/file does not exist then Docker will create it on the host machine and create a directory of the same name in the container.
This issue happened to me as I had a typo in my bind mount.
Windows example
In this scenario Docker would create the following path in the container "/root/.aws/credentitals/" with credentials being a directory.
Hope this helps someone in the future.
Upvotes: 0