-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix containerd non-root script to be a proper entrypoint
- Loading branch information
Showing
5 changed files
with
45 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
FROM tianon/containerd | ||
VOLUME /var/lib/containerd | ||
ENTRYPOINT ["dind"] | ||
ENTRYPOINT ["dind", "docker-entrypoint.sh"] | ||
CMD ["containerd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
# no arguments or first arg is `-f` or `--some-option` | ||
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then | ||
set -- containerd "$@" | ||
fi | ||
|
||
# if we're not root, let's adjust all the "uid" and "gid" parameters of the config to whatever our current user is (so we avoid "chown" permission errors) | ||
uid="$(id -u)"; gid="$(id -g)" | ||
if [ "$uid" != 0 ] && [ "$1" = 'containerd' ]; then | ||
shift | ||
|
||
configDump=( containerd config dump ) | ||
if ! "${configDump[@]}" &> /dev/null; then | ||
configDump=( containerd --config /dev/null config dump ) | ||
"${configDump[@]}" > /dev/null | ||
fi | ||
|
||
exec containerd --config <( | ||
"${configDump[@]}" \ | ||
| awk -v uid="$uid" -v gid="$gid" ' | ||
$1 == "uid" { gsub(/=.+$/, "= " uid) } | ||
$1 == "gid" { gsub(/=.+$/, "= " gid) } | ||
{ print } | ||
' | ||
) "$@" | ||
fi | ||
|
||
exec "$@" |
This file was deleted.
Oops, something went wrong.