- Containerd
#!/bin/bash
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' | # Pluck JSON value
cut -c 2-
}
latest_ver=$(get_latest_release containerd/nerdctl)
if [ -f /usr/local/bin/nerdctl ]; then
echo "${RED}--nerdctl exist.. PASS--${NC}"
else
echo "${RED}--nerdctl Binary downloading...--${NC}"
cd ~/
wget https://github.com/containerd/nerdctl/releases/download/v${latest_ver}/nerdctl-${latest_ver}-linux-amd64.tar.gz
mkdir ./nerdctl-${latest_ver}
tar -xvzf nerdctl-${latest_ver}-linux-amd64.tar.gz -C ./nerdctl-${latest_ver}
cp -r ./nerdctl-${latest_ver}/nerdctl /usr/local/bin/
rm -rf nerdctl-${latest_ver}*
nerdctl version
fi
latest_ver=$(get_latest_release containernetworking/plugins)
if [ -d /opt/cni/bin ]; then
echo "${RED}--CNI plugin exist.. PASS--${NC}"
else
echo "${RED}--CNI plugin downloading...--${NC}"
mkdir -p /opt/cni/bin
cd /opt/cni/bin
wget https://github.com/containernetworking/plugins/releases/download/v${latest_ver}/cni-plugins-linux-amd64-v${latest_ver}.tgz
tar -xvzf cni-plugins-linux-amd64-v${latest_ver}.tgz
rm -rf cni-plugins-linux-amd64-v${latest_ver}.tgz
fi
To run a container with the default bridge
CNI network (10.4.0.0/24):
# nerdctl run -it --rm alpine
To build an image using BuildKit:
# nerdctl build -t foo /some-dockerfile-directory
# nerdctl run -it --rm foo
To build and send output to a local directory using BuildKit:
# nerdctl build -o type=local,dest=. /some-dockerfile-directory
To run containers from docker-compose.yaml
:
# nerdctl compose up -d
# nerdctl compose down
# nerdctl compose -f ./examples/compose-wordpress/docker-compose.yaml up