23

I'm trying to use the docker awslogs driver and getting the following error:

"docker: Error response from daemon: Failed to initialize logging driver: NoCredentialProviders: no valid providers in chain. Deprecated."

According to this GitHub comment, I need to set the AWS_SHARED_CREDENTIALS_FILE environment variable for the docker daemon, but I'm not sure how to do that when using Docker for Mac.

The command I'm using to start the container is:

docker run -d \
 --log-driver=awslogs \
 --log-opt awslogs-region=us-east-1 \
 --log-opt awslogs-group=my-log-group \
 my-image

Version information:

  • Docker for Mac 1.12.1-rc1-beta23 build 11375
  • OS X El Capitan 10.11.6
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Mike Ottum
  • 1,361
  • 1
  • 12
  • 20
  • 1
    What command do you use to start your docker container? – tokeryberg Aug 20 '16 at 09:13
  • @tokeryberg, edited my question to add the command. – Mike Ottum Aug 20 '16 at 19:22
  • Out of curiousity- why would you want the logs from your laptop sent to aws? – Paul Becotte Aug 24 '16 at 17:07
  • It's not a laptop, it's a Mac Mini running as a production server. To answer your follow-up question, the reasons we are using a Mac Mini as a production server are historical / out of necessity. Hopefully we will switch to Ubuntu as the host OS soon, but who knows when that will happen. – Mike Ottum Aug 24 '16 at 21:00
  • 1
    I ended up using https://github.com/nearform/docker-cloudwatch, which has been working well. – Mike Ottum Aug 30 '16 at 18:19

2 Answers2

1

but I'm not sure how to do that when using Docker for Mac.

With boot2docker, you would need to modify /var/lib/boot2docker/profile in order to add this variable.
See "Docker daemon config file on boot2docker".
It does persists across the TinyCore-based VM reboot, and the docker daemon would then take it into account.

With the new docker for Mac xhyve-based, the idea should be the same.
/var/lib/boot2docker/profile does exist as well, as shown in this answer.
The official docker dameon doc points to:

--config-file=/etc/docker/daemon.json  Daemon configuration file

So try and modify this file.

By default, the comments mention:

~/Library/Containers/com.docker.docker/Data/database/com.doc‌​ker.driver.amd64-lin‌​ux/etc/docker/daemon‌​.json
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This didn't work for me. `/var/lib/boot2docker/` didn't exist (I'm using Docker 1.12.1-rc1-beta23 build 11375), so I created it and a profile file, exported AWS_SHARED_CREDENTIALS_FILE in it, and restarted docker, but I got the same error. – Mike Ottum Aug 23 '16 at 16:50
  • @MikeOttum But you are using Docker for Mac, right? I don't remember if that new xhyve version is using boot2docker or not, but if the folder boot2docker does not exist... I suppose not. In that case, try and look at `/usr/lib/systemd/system/docker.service`: IT might reference an Environmentfile which you could modify and add your EXPORT. – VonC Aug 23 '16 at 16:57
  • that's correct, I'm using Docker for Mac on OS X El Capitan 10.11.6. `/usr/lib/systemd` doesn't exist on my system. I did a `find / | grep docker.service` and it came up empty. :-/ – Mike Ottum Aug 24 '16 at 00:21
  • @MikeOttum and `find / |grep docker`? – VonC Aug 24 '16 at 06:32
  • `find / | grep docker` outputs this: https://gist.github.com/ottumm/6b8bf4e9abc6faed14008fa61d2e7f31 – Mike Ottum Aug 24 '16 at 16:45
  • @MikeOttum OK, you output is consistent with a regular docker installation. I have edited my answer. (although https://github.com/docker/docker/issues/21559 is an interesting read) – VonC Aug 24 '16 at 21:21
  • @mik I see it didn't work, I presume? (Since the answer is dowvoted) – VonC Aug 26 '16 at 04:56
  • I didn't downvote your answer. But, no, it didn't work because `/etc/docker` doesn't exist on Docker for Mac. I appreciate all the effort on this, though. I think it's likely that I'm going to give up on using the awslogs driver for now and try a different solution until I can move to Linux. – Mike Ottum Aug 26 '16 at 17:34
  • @MikeOttum I found mine in: `~/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/etc/docker/daemon.json` – Gustavo Hoirisch May 08 '17 at 03:33
0

Using information taken from this answer: Docker deamon config path under mac os

You can connect to the VM layer that runs the docker daemon using:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

And you can modify /etc/docker/daemon.json to add the needed variables there.

Once you make your changes, you can just run:

service docker restart

from within the moby terminal to restart the docker daemon.

Do notice that if you restart docker from your mac, the changes will not persist.

On a side note, if you encounter a login screen when connecting with the screen command, try username: root to access the system.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
aemus
  • 713
  • 4
  • 14
  • I'm able to connect to the screen session (thanks for that!), but I'm not sure what to modify in `/etc/docker/daemon.json` in order to set AWS credentials. I tried setting an export line in `/etc/default/docker` and `/etc/docker/profile` (as mentioned in https://github.com/docker/docker/issues/19392#issuecomment-221654053), but no luck. I think I'm going to go a different direction with this until I can move to Linux, but I appreciate the help. – Mike Ottum Aug 26 '16 at 17:44
  • @MikeOttum You need to modify `/etc/docker/daemon.json` following the example available [here](https://docs.docker.com/v1.10/engine/reference/commandline/daemon/), in the section *Daemon configuration file*. For your convenience, the `daemon.json` file would look something like the following: `{ "storage-driver": "aufs", "debug": true, "log-driver": "awslogs", "log-opts": ["awslogs-region=us-east-1", "awslogs-group=myLogGroup"] }` However, docker restart overrides that file. Probably you'll need to add the variables to: `/etc/init.d/docker` – aemus Sep 08 '16 at 19:58