目录
- 前言
- 1. COPY failed: stat /xxxx: no such file or directory
- 2. invalid from flag value builder: pull access denied for builder, repository does not exist or may require 'docker login'
- 3. failed to pull image "node:alpine" with specified policies [always]: toomanyrequests
- 4. docker: Error response from daemon: Conflict. The container name "/manong-container" is already in use by container "xxxx". You have to remove (or rename) that container to be able to reuse that name.
前言
关于这部分的博客
记录使用gielab-cicd上书写yml遇到的错误
具体错误大致如下,以及我怎么解决这些bug
1. COPY failed: stat /xxxx: no such file or directory
出现如下问题:
Step 8/8 : COPY --from=builder manong/website/manong/dist /usr/share/nginx/html
COPY failed: stat /xxxx: no such file or directory
ERROR: Job failed: exit code 1
关于这个问题,错误日志显示没有这个目录
具体截图如下所示:
解决方法如下:
通过容器进入docker exec -it 容器id /bin/bash
查看其内部文件,因为我是npm build进行打包,可能关键的目录写错了,导致无法复制
通过查看镜像内部的目录结构
找到具体位置即可
2. invalid from flag value builder: pull access denied for builder, repository does not exist or may require ‘docker login’
出现如下问题:
Step 8/8 : COPY --from=builder /manong/dist /home/manong/html
invalid from flag value builder: pull access denied for builder, repository does not exist or may require 'docker login'
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1
具体截图如下所示:
关于这个问题:
docker login的账号密码有无登录
以及登录之后有无将其密钥保存在gitlab中
具体保存在gitlab的方式如下:
variables:
DOCKER_AUTH_CONFIG: '{"auths": {"xxxx": {"auth": "xxxx"}}}'
具体上面的auth,通过服务器上执行这个命令:cat ~/.docker/config.json
3. failed to pull image “node:alpine” with specified policies [always]: toomanyrequests
出现问题如下所示:
Preparing the "docker" executor
Using Docker executor with image node:alpine ...
Pulling docker image node:alpine ...
WARNING: Failed to pull image with policy "always": toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (manager.go:203:3s)
ERROR: Job failed: failed to pull image "node:alpine" with specified policies [always]: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (manager.go:203:3s)
关于这个问题
具体原因是因为docker 在2020年的时候就已经限制次数拉取,匿名用户只能当天只能拉取100次,登录用户次数多一些但也有限制
为了防止这种限制
解决方法就是将镜像打到自已的服务器上或者公司的服务器上
通过服务器进行拉取镜像,避免次数的限制
(通过这里,可看到我当时运行脚本测试或者多个人使用这个脚本部署的时候,次数已经上了限制)
关于怎么使用docker制作镜像打到服务器上
可看我这篇文章:
Docker镜像推送到远程服务器
4. docker: Error response from daemon: Conflict. The container name “/manong-container” is already in use by container “xxxx”. You have to remove (or rename) that container to be able to reuse that name.
出现问题如下所示:
Successfully tagged manongimages:latest
$ if [ $(docker ps -aq --filter name==manong-container) ]; then docker rmi -f manong-container;fi
$ docker run -d -p 8082:80 --name manong-container manongimages
docker: Error response from daemon: Conflict. The container name "/manong-container" is already in use by container "xxxx". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 125
具体截图如下:
关于这个问题
由于我的yml脚本文件是这么书写的:
$ if [ $(docker ps -aq --filter name==manong-container) ]; then docker rmi -f manong-container;fi
$ docker run -d -p 8082:80 --name manong-container manongimages
明明只是创建了manong-container,但是却提示我有这个/manong-container容器
于是我手动删除,第一次运行的时候还是好好的,但是第二次运行又遇到这个错误
百思不得其解
于是我做了如下操作:
$ if [ $(docker ps -aq --filter name==manong-container) ]; then docker rmi -f manong-container;fi
$ if [ $(docker ps -aq --filter name==/manong-container) ]; then docker rmi -f /manong-container;fi
$ docker run -d -p 8082:80 --name manong-container manongimages
但还是出现了同样的错误,这是为什么呢????
我通过docker inspect查询,发现确实有这个/manong-container,而且manong-container也存在
于是我通过其提供的容器id以及docker ps
命令
发现这两个都是同一个东西,那就说明我删除不干净,于是我修改了我的脚本逻辑代码
最后通过了
具体的逻辑代码如下:
- docker build -t manongimages .
- if [ $(docker images -q -f dangling=true) ]; then docker rmi $(docker images -q -f dangling=true); fi #删除none的冗余容器
- if [ $(docker ps -aq --filter name=manong-container) ]; then docker rm -f $(docker ps -aq --filter name=manong-container);fi
- docker run -d -p 8082:80 --name manong-container manongimages # 使用新的容器