Docker
Docker
- awesome-docker : A curated list of Docker resources and project.
- Docker Hub for docker images.
Install docker engine
Please check supported versions first before adding the repository.
sudo apt update && sudo apt install -y ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-pluginNVIDIA GPU support
- Setup nvidia driver. See cuda.
- Install the NVIDIA Container Toolkit
sudo apt install -y --no-install-recommends ca-certificates curl gnupg2
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update && sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart dockerTest docker installation
Test docker
sudo docker run hello-worldTest nvidia GPU support
sudo docker run --gpus all nvidia/cuda:13.0-base nvidia-smi(Optional) add a user to the docker group
So you don’t have to type sudo in docker commands.
sudo usermod -aG docker $USERLog out and log back in apply the change.
Default settings for Docker
The /etc/docker/daemon.json files holds docker settings.
data-root: You can put the Docker data directory to another partition. (using/home/dockerin this example)storage-driver: Set up BTRFS storage driver if the Docker data directory is in a BTRFS partition.registry-mirrors: Set up Google’s pull-through cache to work around the DockerHub’s pull rate limit.
Edit /etc/docker/daemon.json for the following options
/etc/docker/daemon.json
{
"data-root": "/home/docker",
"registry-mirrors": ["https://mirror.gcr.io"],
"storage-driver": "btrfs"
}Then run the following command to apply new docker daemon settings.
sudo service docker restartYou can see the new settings using this command
sudo docker infoMaintenance
For example, removing all unused docker things.
docker system pruneDocumentations and Tutorials for Docker
Docker and GitHub actions
- Docker documentation: Configure GitHub Actions
- How to publish a docker image into the Github package registry
- Running jobs in a container in GitHub actions.
Or use the regular docker run command. Here we use > to fold commands in YAML.
.github/workflows/test-container.yml
name: container
on: push
env:
IMG: "node:14.15.0-alpine3.12"
jobs:
node-docker:
runs-on: ubuntu-latest
steps:
- name: Log the node version
run: >
docker run -rm -v $(pwd):/tmp -w /tmp
${{ env.IMG }}
bash -c "node -v; cat /etc/os-release"Last updated on