apline 镜像修改hosts问题
RUN echo "hosts: files dns" > /etc/nsswitch.conf
docker无法启动
症状:
①Job for docker.service failed because the control process exited with error code. See “systemctl status docker.service”
②Cannot connect to the Docker daemon at unix:///var/run/docker.sock. .
有效解决链接
docker-compose安装
①官网安装方法(需要FQ)
需要安装curl(支持https)curl安装链接
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
②wget安装(需要FQ)
curl方法很容易报错,建议wget安装,与官网安装方法稍不同
sudo wget https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m) -O /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
③以上都很慢很慢很慢…推荐一个下载链接
④pip方法
不推荐,容易安装不全
创建和使用私有仓库
①registry搭建
docker pull registry
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --name myregistry registry
将主机的/opt/registry目录挂载到该目录,实现将镜像保存到主机的/opt/registry目录
创建后浏览器可以访问http://127.0.0.1:5000/v2 链接
②push镜像到registry
docker tag nginx:latest localhost:5000/nginx:latest
docker push localhost:5000/nginx:latest
localhost可设置为本机ip
访问http://127.0.0.1:5000/v2/_catalog 链接
报错:docker registry push错误“server gave HTTP response to HTTPS client”解决办法
③拉取私有仓库的镜像
docker pull localhost:5000/nginx:latest
docker里使用nvidia显卡
官网装nvidia-container-toolkit链接
1.要fq
2.curl失败后,可以把链接复制到浏览器下载,再add
3.sudo apt-get update,有些NVIDIA的网址可能找不到,参考链接
# Add the package repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
以上失败了
有用链接
关键描述
2019年7月的docker 19.03已经正式发布了,这次发布有两大亮点。
1,就是docker不需要root权限来启动和运行了
2,就是支持GPU的增强功能,我们在docker里面想读取nvidia显卡再也不需要额外的安装nvidia-docker了
制作镜像时报错
debconf: delaying package configuration, since apt-utils is not installed
忽略即可,只是告警
docker容器内部连接本机
测试环境:mac m1 && Docker version 20.10.5
host.docker.internal:3306
等同于
127.0.0.1:3306