docker
install
on Linux
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker $USER
# 修改源 /etc/docker/daemon.json
echo '{"registry-mirrors":["https://docker.hjkl01.cn", "https://docker.m.daocloud.io/","https://run-docker.cn","https://docker.sunzishaokao.com"],"dns":["119.29.29.29","114.114.114.114"]}' | sudo tee /etc/docker/daemon.json > /dev/null
# 配置完后需要重启 Docker 服务
sudo systemctl restart docker
on Mac colima
# volumes
colima start --vm-type=vz
colima start --kubernetes=false
vi ~/.colima/default/colima.yaml
# docker: {}
docker:
registry-mirrors:
- https://docker.hjkl01.cn
colima restart
# colima delete
# colima start
use mirror example
# docker pull nginx:latest
docker pull docker.hjkl01.cn/library/nginx:latest # 拉取 Docker 官方镜像
# docker pull quay.io/coreos/etcd:latest
docker pull quay.hjkl01.cn/coreos/etcd:latest # 拉取 Quay 镜像
# docker pull gcr.io/google-containers/busybox:latest
docker pull gcr.hjkl01.cn/google-containers/busybox:latest # 拉取 GCR 镜像
# docker pull k8s.gcr.io/pause:latest
docker pull k8s-gcr.hjkl01.cn/pause:latest # 拉取 k8s.gcr.io 镜像
# docker pull registry.k8s.io/pause:latest
docker pull k8s.hjkl01.cn/pause:latest # 拉取 registry.k8s.io 镜像
# docker pull ghcr.io/github/super-linter:latest
docker pull ghcr.hjkl01.cn/github/super-linter:latest # 拉取 GitHub 容器镜像
# docker pull docker.cloudsmith.io/public/repo/image:latest
docker pull cloudsmith.hjkl01.cn/public/repo/image:latest # 拉取 Cloudsmith 镜像
常用命令
# export
docker save -o <path for generated tar file> <image name>
example: docker save -o ./centos.tar centos:16
# load
docker load -i <path to image tar file>
# run image
docker run -it --rm ubuntu bash
# exec container
docker exec -it openwrt zsh
# tail log
docker logs -f --tail 100 9f7d