Skip to content

Instantly share code, notes, and snippets.

@peteryhwong
Created October 2, 2022 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peteryhwong/a51c39d69647c233808339c62d7b8f28 to your computer and use it in GitHub Desktop.
Save peteryhwong/a51c39d69647c233808339c62d7b8f28 to your computer and use it in GitHub Desktop.
Script to start dockerd inside CodeBuild
#! /bin/sh
# See if docker is running or start the dockerd
# https://github.com/aws/aws-codebuild-docker-images/issues/164#issuecomment-460324202
# https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html#sample-docker-custom-image-files
dockerrunning=$(docker info &>/dev/null && echo -n "docker running" || echo -n "docker not running")
if [[ "$dockerrunning" = "docker not running" ]]; then
nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &>/var/log/docker.log &
timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment