docker部署应用时超时解决

错误:

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.1:build (build-image) on project freemarker-page-demo: Exception caught: Get https://registry-1.docker.io/v2/library/java8/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fjava8%3Apull&service=registry.docker.io: net/http: TLS handshake timeout -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Get https://registry-1.docker.io/v2/: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

解决方案:更换国内镜像服务器。

换了好几台,科大的,还有一些其他的,都是不行。决定试用镜像加速器。

登录阿里云控制台,产品中搜索镜像,选择镜像加速器,复制加速器地址。

将加速器地址,更新到/etc/docker/daemon.json中

{
"registry-mirrors": ["https://jvqgqnis.mirror.aliyuncs.com"]
}

居然又报下面错误:

curl https://registry-1.docker.io/v2/,发现需要认证。看来是auth.docker.io这个域名超时了。

Get https://registry-1.docker.io/v2/library/java/manifests/8: Get https://auth.docker.io/token?account=zhouyu629&scope=repository%3Alibrary%2Fjava%3Apull&service=registry.docker.io: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

试试docker login

 
[root@localhost fpage]# docker login
Authenticating with existing credentials...
Login did not succeed, error: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (zhouyu629): zhouyu629
Password: 
Error response from daemon: Get https://registry-1.docker.io/v2/: Get https://auth.docker.io/token?account=zhouyu629&client_id=docker&offline_token=true&service=registry.docker.io: net/http: request canceled (Client.Timeout exceeded while awaiting headers) (Client.Timeout exceeded while awaiting headers)

果然不行。试用用chrome浏览auth这个域名,果然一会能打开,刷新一下又不行了,看来是不稳定。

白天在公司还行,家里网络不行,试了host和resovle,都不行。明天再到公司试下。

20200310

在公司网络下,果然可以了。看来家里网络还是有问题。

网络问题解决了,又出现一个新问题:no space left

docker info:
Storage Driver: overlay2

再 df -kh,看了下overlay空间不足

文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 903M     0  903M    0% /dev
tmpfs                    919M     0  919M    0% /dev/shm
tmpfs                    919M  9.1M  910M    1% /run
tmpfs                    919M     0  919M    0% /sys/fs/cgroup
/dev/mapper/centos-root  6.2G  5.7G  521M   92% /
/dev/sda4                 19G   81M   18G    1% /home
/dev/sda1               1014M  219M  796M   22% /boot
tmpfs                    184M     0  184M    0% /run/user/0
overlay                  6.2G  5.7G  521M   92% /var/lib/docker/overlay2/471243d367850d452e94d3e7740c7026a2f0320af68b402fe6a28705d63536ff/merged
tmpfs                    184M     0  184M    0% /run/user/1000

把/var/lib/docker 移到home,再做个快捷方式链接过去。

 
[root@localhost /]# service docker stop
Redirecting to /bin/systemctl stop docker.service
[root@localhost /]# mv /var/lib/docker /home/
[root@localhost /]# ln -s /home/docker/ /var/lib/
[root@localhost /]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@localhost /]# df -kh
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 903M     0  903M    0% /dev
tmpfs                    919M     0  919M    0% /dev/shm
tmpfs                    919M  9.1M  910M    1% /run
tmpfs                    919M     0  919M    0% /sys/fs/cgroup
/dev/mapper/centos-root  6.2G  5.6G  655M   90% /
/dev/sda4                 19G  215M   18G    2% /home
/dev/sda1               1014M  219M  796M   22% /boot
tmpfs                    184M     0  184M    0% /run/user/0
tmpfs                    184M     0  184M    0% /run/user/1000
overlay                   19G  215M   18G    2% /home/docker/overlay2/471243d367850d452e94d3e7740c7026a2f0320af68b402fe6a28705d63536ff/merged

再 docker build终于成功了:

 
[root@localhost fpage]# docker build -t boot-docker .
Sending build context to Docker daemon   12.8kB
Step 1/6 : FROM java:8
8: Pulling from library/java
5040bd298390: Pull complete 
fce5728aad85: Pull complete 
76610ec20bf5: Pull complete 
60170fec2151: Pull complete 
e98f73de8f0d: Pull complete 
11f7af24ed9c: Pull complete 
49e2d6393f32: Pull complete 
bb9cdec9c7f3: Pull complete 
Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
Status: Downloaded newer image for java:8
 ---> d23bdf5b1b1b
Step 2/6 : VOLUME /home
 ---> Running in 567eb55489ee
Removing intermediate container 567eb55489ee
 ---> 2697773d05bd
Step 3/6 : COPY freemarker-page-demo-1.0-SNAPSHOT.jar page.jar
 ---> bd0e15853a86
Step 4/6 : RUN bash -c "touch /page.jar"
 ---> Running in 9ca6ad3a6eca
Removing intermediate container 9ca6ad3a6eca
 ---> fbd2d53d16ba
Step 5/6 : EXPOSE 8080
 ---> Running in 8a4d61f14ffb
Removing intermediate container 8a4d61f14ffb
 ---> 7a221e5fb012
Step 6/6 : ENTRYPOINT ["java","-jar","page.jar","--server.port=8080","> /home/log/page.log"]
 ---> Running in 28795c5e40dc
Removing intermediate container 28795c5e40dc
 ---> d83747d5a950
Successfully built d83747d5a950
Successfully tagged boot-docker:latest

 

posted on 2020-03-11 09:16  zhouyu  阅读(7515)  评论(0编辑  收藏  举报

导航