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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM