File: //snap/docker/current/snap/snapcraft.yaml
name: docker
version: '29.8.0'
summary: Docker container runtime
description: Refer to https://snapcraft.io/docker
license: (Apache-2.0 AND MIT AND GPL-2.0)
grade: stable
confinement: strict
base: core24
assumes:
- snapd2.59.1
layout:
/etc/docker:
bind: $SNAP_DATA/etc/docker
/etc/gitconfig:
bind-file: $SNAP_DATA/etc/gitconfig
/usr/libexec/docker/cli-plugins:
symlink: $SNAP/usr/libexec/docker/cli-plugins
environment:
DEFAULT_DATA_ROOT: "$SNAP_COMMON/var-lib-docker"
GIT_EXEC_PATH: "$SNAP/usr/lib/git-core"
GIT_TEMPLATE_DIR: "$SNAP/usr/share/git-core/templates"
# For nvidia support #
LD_LIBRARY_PATH: $SNAP/graphics/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:${SNAP}/lib/:${SNAP}/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:${SNAP}/usr/lib/:${SNAP}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}
LIBGL_DRIVERS_PATH: $SNAP/graphics/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/dri
LIBVA_DRIVERS_PATH: $SNAP/graphics/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/dri
# nvidia-container-runtime can only set alternative config directory via XDG_CONFIG_HOME #
XDG_CONFIG_HOME: $SNAP_DATA/etc
plugs:
home:
read: all
support:
interface: docker-support
privileged:
interface: docker-support
privileged-containers: true
docker-cli:
interface: docker
opengl:
# For nvidia userspace libs support #
gpu-2404:
interface: content
target: $SNAP/gpu-2404
# This is the only relevant provider, but leaving unspecified to prevent auto-installing of the providing snap #
# default-provider: mesa-2404
graphics-core22:
interface: content
target: $SNAP/graphics
# Currently, this is the only relevant provider, but cannot be default as not supported on all archs #
#default-provider: nvidia-core22
slots:
config-ro:
interface: content
content: docker-config-ro
read:
- $SNAP_DATA/config
docker-daemon:
interface: docker
docker-executables:
content: docker-executables
interface: content
read:
- .
docker-registry-certificates:
content: docker-registry-certificates
interface: content
write:
- $SNAP_DATA/etc/docker/certs.d
apps:
docker:
command: bin/docker
completer: bin/docker-completion.sh
plugs:
- docker-cli
- network
- home
- removable-media
dockerd:
command: bin/dockerd-wrapper
daemon: simple
plugs:
- removable-media
- firewall-control
- home
- log-observe
- network-bind
- network-control
- privileged
- support
- gpu-2404
- graphics-core22
slots:
- docker-daemon
compose:
command: usr/libexec/docker/cli-plugins/docker-compose
plugs:
- removable-media
- docker-cli
- network
- home
nvidia-container-toolkit:
command-chain:
- bin/system-detection
command: bin/nvidia-container-toolkit
daemon: oneshot
plugs:
- gpu-2404
- graphics-core22
before:
- dockerd
parts:
utility-scripts:
plugin: dump
source: .
stage-packages:
- mount
- nftables
organize:
nvidia/lib: usr/share/nvidia-container-toolkit/lib
nvidia/nvidia-container-toolkit: bin/
nvidia/nvidia-container-toolkit-connect-hook: bin/
nvidia/system-detection: bin/
nvidia/gpu-2404-optional-wrapper: bin/
stage:
- bin/*
- usr/sbin/*
- config/daemon.json
- lib/daemon-config
- patches/*
- usr/share/nvidia-container-toolkit/*
prime:
- -bin/go-build-helper.sh
- -patches/*
- bin/*
- usr/sbin/*
- config/daemon.json
- lib/daemon-config
- usr/share/nvidia-container-toolkit/*
utils:
plugin: nil
stage-packages:
- jq
- pciutils
engine:
plugin: make
source: https://github.com/moby/moby.git
source-tag: docker-v$CRAFT_PROJECT_VERSION
source-depth: 1
override-build: |
$CRAFT_STAGE/patches/patch.sh
# docker build specific environment variables
export VERSION=$(craftctl get version)
export DOCKER_GITCOMMIT=$(git rev-parse --short HEAD)
export GITCOMMIT=$DOCKER_GITCOMMIT
export DISABLE_WARN_OUTSIDE_CONTAINER=1
export DOCKER_BUILDTAGS='apparmor seccomp selinux'
# setup the go build environment for docker/docker
. "$CRAFT_STAGE/bin/go-build-helper.sh"
gopartbootstrap github.com/docker/docker
# build the dockerd binary
./hack/make.sh dynbinary
install -d "$CRAFT_PART_INSTALL/bin"
install -T bundles/dynbinary-daemon/dockerd "$CRAFT_PART_INSTALL/bin/dockerd"
# install docker-proxy previously provided by libnetwork part
install -T bundles/dynbinary-daemon/docker-proxy "$CRAFT_PART_INSTALL/bin/docker-proxy"
build-snaps: &go ['go/1.26/stable']
# we get weird behavior if we mix/match Go versions throughout this one snapcraft.yml, so we use a YAML reference here to ensure we're always consistent throughout
after: [utility-scripts]
build-packages:
- btrfs-progs
- gcc
- git
- libc6-dev
- libdevmapper-dev
- libltdl-dev
- libsystemd-dev
- libnftables-dev
- patch
- pkg-config
- to armhf:
- execstack
stage-packages:
- git
- libltdl7
- libjansson4
- libnftables1
- pigz
- xz-utils
- zfsutils-linux
override-stage: |
craftctl default
# clear executable stack flag bit on libzpool (from zfsutils-linux) when building for armhf
# to satisfy store validation
#
# we do it in override-stage because libzpool comes from stage-packages and therefore only exists in $CRAFT_STAGE
if [ "${CRAFT_ARCH_BUILD_FOR}" = "armhf" ]; then
find "$CRAFT_STAGE" -name "libzpool.so.*" -exec execstack --clear-execstack {} \;
fi
containerd:
plugin: make
source: https://github.com/containerd/containerd.git
source-tag: v2.3.4
source-depth: 1
override-build: |
make GIT_COMMIT= GIT_BRANCH= LDFLAGS=
rm bin/containerd-stress
install -d "$CRAFT_PART_INSTALL/bin"
install -t "$CRAFT_PART_INSTALL/bin" bin/containerd* bin/ctr
build-snaps: *go
build-packages:
- libbtrfs-dev
runc:
plugin: make
source: https://github.com/opencontainers/runc.git
source-tag: v1.5.1
source-depth: 1
override-build: |
make BUILDTAGS='seccomp apparmor selinux' COMMIT=
install -d "$CRAFT_PART_INSTALL/bin"
install -T runc "$CRAFT_PART_INSTALL/bin/runc"
build-snaps: *go
build-packages:
- libapparmor-dev
- libseccomp-dev
nvidia-container-toolkit:
plugin: go
source: https://github.com/NVIDIA/nvidia-container-toolkit.git
source-tag: v1.19.1
source-depth: 1
override-pull: &arch-restrict |
[ "${CRAFT_ARCH_BUILD_FOR}" != "amd64" ] && \
[ "${CRAFT_ARCH_BUILD_FOR}" != "arm64" ] && \
exit 0
[ "${CRAFT_STEP_NAME}" = "BUILD" ] && $CRAFT_STAGE/patches/patch.sh
craftctl default
override-build: *arch-restrict
override-stage: *arch-restrict
override-prime: *arch-restrict
build-snaps: *go
build-packages:
- make
- libtirpc-dev
organize:
bin: usr/bin/
stage:
- usr/bin/nvidia-container-*
- usr/bin/nvidia-ctk
- usr/bin/nvidia-cdi-hook
libnvidia-container:
plugin: make
source: https://github.com/NVIDIA/libnvidia-container.git
source-tag: v1.19.0
source-depth: 1
override-pull: *arch-restrict
override-build: *arch-restrict
override-stage: *arch-restrict
override-prime: *arch-restrict
after: [utility-scripts]
build-packages:
- bmake
- curl
- libelf-dev
- libcap-dev
# Paths taken from upstream packaging #
organize:
usr/local/bin/nvidia-container-cli: usr/bin/nvidia-container-cli
usr/local/lib: usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/
prime:
- usr/bin/nvidia-container-cli*
- usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libnvidia-container*.so*
tini:
plugin: cmake
source: https://github.com/krallin/tini.git
source-type: git
source-tag: v0.19.0
source-depth: 1
organize:
'usr/local/bin/tini-static': bin/docker-init
build-packages:
- build-essential
prime:
- -usr/local/bin/tini
docker-cli:
plugin: make
build-snaps: *go
source: https://github.com/docker/cli.git
source-tag: v$CRAFT_PROJECT_VERSION
source-depth: 1
override-build: |
# docker build specific environment variables
export VERSION=$(craftctl get version)
export DOCKER_GITCOMMIT=$(git rev-parse --short HEAD)
export GITCOMMIT=$DOCKER_GITCOMMIT
export DISABLE_WARN_OUTSIDE_CONTAINER=1
# setup the go build environment for docker-cli
. $CRAFT_STAGE/bin/go-build-helper.sh
gopartbootstrap github.com/docker/cli
# build the docker cli binary
unset LDFLAGS
make binary
install -d "$CRAFT_PART_INSTALL/bin"
install -T build/docker "$CRAFT_PART_INSTALL/bin/docker"
install -T contrib/completion/bash/docker "$CRAFT_PART_INSTALL/bin/docker-completion.sh"
after: [utility-scripts]
stage-packages:
- git
buildx:
plugin: nil
source: https://github.com/docker/buildx.git
source-tag: v0.37.0
source-depth: 1
override-build: |
export DESTDIR="$CRAFT_PART_INSTALL/usr/libexec/docker/cli-plugins"
export VERSION=$(git describe --match 'v[0-9]*' --always --tags)
export REVISION=$(git rev-parse HEAD)
export PACKAGE=github.com/docker/buildx
export GO_PKG=github.com/docker/buildx
export GO_LDFLAGS="-X ${GO_PKG}/version.Version=${VERSION} -X ${GO_PKG}/version.Revision=${REVISION} -X ${GO_PKG}/version.Package=${PACKAGE}"
export GO_EXTRA_LDFLAGS="-s -w"
go build -trimpath -ldflags "${GO_LDFLAGS} ${GO_EXTRA_LDFLAGS}" -o "${DESTDIR}/docker-buildx" ./cmd/buildx
build-snaps: *go
compose:
plugin: make
source: https://github.com/docker/compose.git
source-tag: v5.5.1
source-depth: 1
override-build: |
make build
install -d "$CRAFT_PART_INSTALL/usr/libexec/docker/cli-plugins"
install -T bin/build/docker-compose "$CRAFT_PART_INSTALL/usr/libexec/docker/cli-plugins/docker-compose"
build-snaps: *go
lint:
ignore:
# Change to unused-library, once available
- library:
- usr/lib/**/libltdl.so.*
- usr/lib/**/libnvidia-container-go.so.*
# vim:set et ts=2 sw=2: