{"id":192339,"date":"2020-06-09T08:00:40","date_gmt":"2020-06-09T00:00:40","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=192339"},"modified":"2020-05-25T09:54:15","modified_gmt":"2020-05-25T01:54:15","slug":"docker-yum-error","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/docker-yum-error.html","title":{"rendered":"\u89e3\u51b3Docker\u8c03\u7528yum\u62a5\u9519\u7684\u95ee\u9898"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u672c\u7bc7\u6587\u7ae0\u91cc\u5c0f\u7f16\u7ed9\u5927\u5bb6\u5206\u4eab\u7684\u662f\u5173\u4e8edocker\u5bb9\u5668\u8c03\u7528yum\u62a5\u9519\u7684\u89e3\u51b3\u529e\u6cd5\uff0c\u6709\u5174\u8da3\u7684\u670b\u53cb\u4eec\u53ef\u4ee5\u53c2\u8003\u4e0b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

dockerfile\u91cc\u6216\u8005\u5728\u5bb9\u5668\u91cc\u6267\u884cyum\uff0c\u62a5\u9519\uff0c\u627e\u4e0d\u5230\u6e90(invalid baseurl xxx)\uff0c\u4f46\u662f\u5bbf\u4e3b\u673a\u4e0a\u6267\u884cyum\u662f\u6ca1\u95ee\u9898\u7684\u554a\uff0c\u4e3a\u4ec0\u4e48\uff1f<\/p>\n

\u56e0\u4e3a\u4e0d\u8bba\u662fdockerfile\u4f7f\u7528RUN\u5173\u952e\u5b57\u6267\u884cyum\u8fd8\u662f\u76f4\u63a5\u8fdb\u5165\u5230\u5bb9\u5668\u91cc\u9762\u6267\u884cyum\uff0c\u5b83\u4eec\u90fd\u662f\u4f7f\u7528\u7684docker\u955c\u50cf\u91cc\u9762\u7684\u6e90(CentOS\u662f\u5728\u8def\u5f84\/etc\/yum.repo.d\/CentOS-Base.repo)\uff0c\u6240\u4ee5\u4f60\u8981\u628a\u5bbf\u4e3b\u673a\u4e0a\u7684\u540c\u8def\u5f84\u4e0b\u7684\u6e90\u62f7\u8d1d\u5230\u5bb9\u5668\u91cc\u9762\uff0c\u7136\u540edocker commit\u4e00\u4e2a\u65b0\u7684\u201c\u57fa\u7840\u955c\u50cf\u201d\uff0c\u8fd9\u4e2a\u65f6\u5019\u4f7f\u7528docker build xxx(\u5373\u4f7f\u7528Dockerfile\u7684\u65b9\u5f0f)\u5c31\u4e0d\u4f1a\u62a5\u9519\u4e86\u3002<\/p>\n

\u62f7\u8d1d\u65b9\u6cd5docker cp xxx xxx<\/p>\n

dockerfile\u4e2d\u6267\u884cyum\u64cd\u4f5c\u62a5\u9519<\/strong><\/div>\n

\u6211\u4eec\u5148\u770b\u4e0b\u62a5\u9519\u4fe1\u606f\uff1a<\/p>\n

\r\nSending build context to Docker daemon 9.363 MB\r\nStep 1 : FROM docker.io\/centos\r\n---> 196e0ce0c9fb\r\nStep 2 : MAINTAINER liuliangliang\r\n---> Using cache\r\n---> 7d7e06799c20\r\nStep 3 : ADD file\/tomcat7.tgz \/usr\/local\/\r\n---> Using cache\r\n---> 10ffdea53a02\r\nStep 4 : RUN yum install java-1.8.0-openjdk -y\r\n---> Running in 7824a339e077\r\nLoaded plugins: fastestmirror, ovl\r\n\r\n\r\nOne of the configured repositories failed (Unknown),\r\nand yum doesn't have enough cached data to continue. At this point the only\r\nsafe thing yum can do is fail. There are a few ways to work \"fix\" this:\r\n\r\n1. Contact the upstream for the repository and get them to fix the problem.\r\n\r\n2. Reconfigure the baseurl\/etc. for the repository, to point to a working\r\nupstream. This is most often useful if you are using a newer\r\ndistribution release than is supported by the repository (and the\r\npackages for the previous distribution release still work).\r\n\r\n3. Run the command with the repository temporarily disabled\r\nyum --disablerepo= ...\r\n\r\n4. Disable the repository permanently, so yum won't use it by default. Yum\r\nwill then just ignore the repository until you permanently enable it\r\nagain or use --enablerepo for temporary usage:\r\n\r\nyum-config-manager --disable <\/repoid>\r\nor\r\nsubscription-manager repos --disable=<\/repoid>\r\n\r\n5. Configure the failing repository to be skipped, if it is unavailable.\r\nNote that yum will try to contact the repo. when it runs most commands,\r\nso will have to try and fail each time (and thus. yum will be be much\r\nslower). If it is a very temporary problem though, this is often a nice\r\ncompromise:\r\n\r\nyum-config-manager --save --setopt=<\/repoid>.skip_if_unavailable=true\r\n\r\nCannot find a valid baseurl for repo: base\/7\/x86_64\r\nCould not retrieve mirrorlist http:\/\/mirrorlist.centos.org\/?release=7&arch=x86_64&repo=os&infra=container error was\r\n14: curl#6 - \"Could not resolve host: mirrorlist.centos.org; Unknown error\"\r\nThe command '\/bin\/sh -c yum install java-1.8.0-openjdk -y' returned a non-zero code: 1\r\n<\/repoid><\/pre>\n
\u89e3\u51b3\u65b9\u6cd5<\/strong><\/div>\n

\u8fd9\u4e2a\u4f60\u5728resolv.conf\u6587\u4ef6\u91cc\u52a0\u4e0a DNS\u670d\u52a1\u5c31\u884c\u4e86 \u8fd9\u4e2a\u6587\u4ef6\u5728\/etc\u4e0b\uff0c \u52a0\u4e0a<\/p>\n

\r\nnameserver 8.8.8.8\r\nnameserver 8.8.4.4\r\nsearch localdomain\r\n<\/pre>\n

\u5c31\u884c\u4e86<\/p>\n

\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8edocker\u5bb9\u5668\u8c03\u7528yum\u62a5\u9519\u7684\u89e3\u51b3\u529e\u6cd5\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

dockerfile\u91cc\u6216\u8005\u5728\u5bb9\u5668\u91cc\u6267\u884cyum\uff0c\u62a5\u9519\uff0c\u627e\u4e0d\u5230\u6e90(invalid baseurl xxx)\uff0c\u4f46\u662f\u5bbf […]<\/p>\n","protected":false},"author":63,"featured_media":192340,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-192339","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=192339"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192339\/revisions"}],"predecessor-version":[{"id":192474,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192339\/revisions\/192474"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/192340"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=192339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=192339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=192339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}