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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Docker部署Freemarker,首先需要确保你已经安装了Docker并成功登录到Docker Hub。根据提供的引用内容,看起来你在登录遇到了一些问题。错误消息"Get https://registry-1.docker.io/v2/: net/http: request canceled"和"Get https://auth.docker.io/token?account=zhouyu629&amp;client_id=docker&amp;offline_token=true&amp;service=registry.docker.io: net/http: request canceled"表明你的请求超时了。 为了解决这个问题,你可以尝试以下几个步骤: 1. 确保你的网络连接正常,可以访问Docker Hub的服务器。你可以尝试在浏览器中访问https://hub.docker.com,如果无法访问,则可能是网络问题。 2. 如果你使用的是代理服务器,请确保在Docker配置文件中正确配置了代理设置。 3. 尝试使用不同的网络环境,***了Docker的访问。 一旦你成功解决了登录问题并成功登录到Docker Hub,你就可以开始部署Freemarker了。关于如何部署Freemarker,可以参考一份全面介绍Docker技术的文档。这份文档包括了Docker的基本概念、使用方法和常见问题解决方案,以及Docker在开发、部署和管理中的应用。你可以在该文档中查找有关如何部署Freemarker的详细步骤和示例。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [docker部署应用超时解决](https://blog.csdn.net/zhouyu629/article/details/115652878)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Docker学习文档,全面介绍Docker技术](https://download.csdn.net/download/Goligory/88280848)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值