mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 22:23:07 +00:00
9036ce9af3
The `local` logging driver captures output from container’s stdout/stderr and writes them to an internal storage that is optimized for performance and disk use. We also want to capture these logs on startup to wait for success/failure. Advise the use of `--privileged` when running Docker-in-Docker to avoid various permissions issues encountered in testing. Change-type: patch Changlelog-entry: docker: Improve handling of Docker-in-Docker errors Signed-off-by: Kyle Harding <kyle@balena.io>
36 lines
1018 B
Bash
36 lines
1018 B
Bash
#!/bin/bash
|
|
|
|
# start dockerd if env var is set
|
|
if [ "${DOCKERD}" = "1" ]
|
|
then
|
|
[ -e /var/run/docker.sock ] && rm /var/run/docker.sock
|
|
dockerd --log-driver=local 2>&1 | tee /tmp/dockerd.log &
|
|
while ! grep -q 'API listen on' /tmp/dockerd.log
|
|
do
|
|
grep -q 'Error starting daemon' /tmp/dockerd.log && exit 1
|
|
sleep 1
|
|
done
|
|
fi
|
|
|
|
# load private ssh key if one is provided
|
|
if [ -n "${SSH_PRIVATE_KEY}" ]
|
|
then
|
|
# if an ssh agent socket was not provided, start our own agent
|
|
[ -e "${SSH_AUTH_SOCK}" ] || eval "$(ssh-agent -s)"
|
|
echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
|
|
fi
|
|
|
|
# space-separated list of balena CLI commands (filled in through `sed`
|
|
# in a Dockerfile RUN instruction)
|
|
CLI_CMDS="help"
|
|
|
|
# treat the provided command as a balena CLI arg...
|
|
# 1. if the first word matches a known entry in CLI_CMDS
|
|
# 2. OR if the first character is a hyphen (eg. -h or --debug)
|
|
if [[ " ${CLI_CMDS} " =~ " ${1} " ]] || [ "${1:0:1}" = "-" ]
|
|
then
|
|
exec balena "$@"
|
|
else
|
|
exec "$@"
|
|
fi
|