Ubuntu利用docker搭建Java相关环境问题记录

Docker拉取镜像超时

报错
bash 复制代码
Unable to find image 'dpanel/dpanel:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/  ": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

解决方式

在etc/docker/目录下创建daemon.json文件,将下面内容粘贴进去。

bash 复制代码
{
  "registry-mirrors": [
	"https://registry.cn-hangzhou.aliyuncs.com",
        "https://do.nark.eu.org",
        "https://dc.j8.work",
        "https://docker.m.daocloud.io",
        "https://dockerproxy.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}

docker重新加载文件,然后重启;

bash 复制代码
sudo systemctl daemon-reload
sudo systemctl restart docker
命令方式操作
bash 复制代码
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
	"https://registry.cn-hangzhou.aliyuncs.com",
        "https://do.nark.eu.org",
        "https://dc.j8.work",
        "https://docker.m.daocloud.io",
        "https://dockerproxy.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

镜像被多个仓库引用

报错
bash 复制代码
Error response from daemon: conflict: unable to delete c2a6a40506b9 (must be forced) - image is referenced in multiple repositories
解决方式
  1. 查看镜像引用
bash 复制代码
docker images
  1. 删除镜像引用
bash 复制代码
docker rmi <镜像名称>:<标签>
  1. 强制删除镜像
    如果镜像仍然无法删除,可以使用 -f 或 --force 选项强制删除:
bash 复制代码
docker rmi -f  <镜像名称/id>

Docker未正确登录到镜像仓库,或权限不足

报错:
bash 复制代码
docker push crpi-5qc4odiityxeoecl.cn-hangzhou.personal.cr.aliyuncs.com/aliyun-namespace-lym/dpanel/dpanel:latest
The push refers to repository [crpi-5qc4odiityxeoecl.cn-hangzhou.personal.cr.aliyuncs.com/aliyun-namespace-lym/dpanel/dpanel]
5f70bf18a086: Preparing 
663fbf8d6b31: Preparing 
37ae894d7828: Preparing 
618509a5037e: Preparing 
645a17712757: Preparing 
e48cf4869d45: Waiting 
a49ad3c60d1c: Waiting 
3ac371982ee8: Waiting 
08000c18d16d: Waiting 
denied: requested access to the resource is denied
解决方式
  1. 登录到目标镜像仓库
bash 复制代码
docker login xxx.xxx.xxx.cr.aliyuncs.com
  1. 重新配置镜像仓库
    如果问题仍然存在,可以尝试重新配置镜像仓库
    2.1. 删除镜像仓库。
    2.2. 重新创建镜像仓库。
    2.3. 重新推送镜像

docker-compose.yml文件配置错误

报错
bash 复制代码
compose up 
yaml: unmarshal errors:
  line 109: mapping key "networks" already defined at line 107
解决

确保 networks 部分只定义一次。如果需要定义多个网络,应该将它们放在同一个 networks 部分下。例如:

yml 复制代码
networks:
  my_network:
    driver: bridge
  another_network:
    driver: bridge

未在 docker-compose.yml文件所在目录启动

报错
bash 复制代码
docker compose up 
no configuration file provided: not found
解决

指定配置文件路径

bash 复制代码
docker compose -f /path/to/docker-compose.yml up
相关推荐
鬼手点金3 分钟前
opencode-crawl4ai使用建议
java·开发语言·人工智能·python·机器学习
专业程序开发源17 分钟前
springboot校园志愿者管理系统28562-计算机课程设计、毕业设计
java·spring boot·后端·python·django·php·课程设计
thefool11226621 分钟前
多线程 2
java
奔跑的大白啊9 小时前
多容器共享目录权限踩坑记
linux·ubuntu·共享目录·linux权限·docker 容器化部署
daidaidaiyu10 小时前
ThingsBoard 集群的核心逻辑源码分析
java
我可能是个假开发11 小时前
FTP Unicode 文件名导致 `550` 的问题分析与解决方案
java·开发语言·spring
caoerzhong11 小时前
中小企业上 WMS 该先上哪几块:JeeWMS 开源 Java 仓库管理系统的分批上线清单
java·python·开源
【JAVA】玩家12 小时前
Spring核心原理全解析:从零到生产实战
java·后端·spring
Wang's Blog12 小时前
Java框架 SpringCloud 快速入门: 实现 Feign 最佳实践(抽取方式)
java·spring cloud
MandalaO_O13 小时前
IDEA 开发(快捷键 + 调试 + 序列化)
java·ide·intellij-idea