{"id":110908,"date":"2024-11-30T02:35:10","date_gmt":"2024-11-29T18:35:10","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=110908"},"modified":"2024-11-30T02:35:11","modified_gmt":"2024-11-29T18:35:11","slug":"dockerfile-create-mirror","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/dockerfile-create-mirror.html","title":{"rendered":"\u4e00\u8d77\u8ddf\u6211\u6765\u5b66dockerfile\u521b\u5efa\u955c\u50cf"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Docker \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5e94\u7528\u5bb9\u5668\u5f15\u64ce\uff0c\u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u6253\u5305\u4ed6\u4eec\u7684\u5e94\u7528\u4ee5\u53ca\u4f9d\u8d56\u5305\u5230\u4e00\u4e2a\u53ef\u79fb\u690d\u7684\u5bb9\u5668\u4e2d\uff0c\u7136\u540e\u53d1\u5e03\u5230\u4efb\u4f55\u6d41\u884c\u7684 Linux \u673a\u5668\u4e0a\uff0c\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u865a\u62df\u5316\u3002\u5bb9\u5668\u662f\u5b8c\u5168\u4f7f\u7528\u6c99\u7bb1\u673a\u5236\uff0c\u76f8\u4e92\u4e4b\u95f4\u4e0d\u4f1a\u6709\u4efb\u4f55\u63a5\u53e3\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n docker\u547d\u4ee4\u8bed\u6cd5<\/strong><\/div>\n 1.ADD\r\nADD\u547d\u4ee4\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u6e90\u548c\u76ee\u6807\u3002\u5b83\u7684\u57fa\u672c\u4f5c\u7528\u662f\u4ece\u6e90\u7cfb\u7edf\u7684\u6587\u4ef6\u7cfb\u7edf\u4e0a\u590d\u5236\u6587\u4ef6\u5230\u76ee\u6807\u5bb9\u5668\u7684\u6587\u4ef6\u7cfb\u7edf\u3002\u5982\u679c\u6e90\u662f\u4e00\u4e2aURL\uff0c\u90a3\u8be5URL\u7684\u5185\u5bb9\u5c06\u88ab\u4e0b\u8f7d\u5e76\u590d\u5236\u5230\u5bb9\u5668\u4e2d\r\nADD \/my_app_folder \/my_app_folder\r\n\r\n2.ENTRYPOINT\r\n\u914d\u7f6e\u5bb9\u5668\u542f\u52a8\u540e\u6267\u884c\u7684\u547d\u4ee4\uff0c\u5e76\u4e14\u4e0d\u53ef\u88ab docker run \u63d0\u4f9b\u7684\u53c2\u6570\u8986\u76d6\uff0c\u6bcf\u4e2a Dockerfile \u4e2d\u53ea\u80fd\u6709\u4e00\u4e2a ENTRYPOINT\uff0c\u5f53\u6307\u5b9a\u591a\u4e2a\u65f6\uff0c\u53ea\u6709\u6700\u540e\u4e00\u4e2a\u8d77\u6548\u3002\r\n\r\n3.ENV \r\nENV\u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u8fd9\u4e9b\u53d8\u91cf\u4ee5\u201dkey=value\u201d\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u5e76\u53ef\u4ee5\u5728\u5bb9\u5668\u5185\u88ab\u811a\u672c\u6216\u8005\u7a0b\u5e8f\u8c03\u7528\u3002\u8fd9\u4e2a\u673a\u5236\u7ed9\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u5e94\u7528\u5e26\u6765\u4e86\u6781\u5927\u7684\u4fbf\u5229\u3002 \r\nENV PATH \/usr\/local\/nginx\/sbin:$PATH\r\n\r\n4.EXPOSE \r\nEXPOSE\u7528\u6765\u6307\u5b9a\u7aef\u53e3\uff0c\u4f7f\u5bb9\u5668\u5185\u7684\u5e94\u7528\u53ef\u4ee5\u901a\u8fc7\u7aef\u53e3\u548c\u5916\u754c\u4ea4\u4e92\u3002 \r\nEXPOSE 80\r\n\r\n5.FROM \r\n\u8fd9\u4e2a\u547d\u4ee4\u7528\u4e8e\u58f0\u660e\u4f5c\u8005\uff0c\u5e76\u5e94\u8be5\u653e\u5728FROM\u7684\u540e\u9762\u3002 \r\nMAINTAINER authors_name \r\n\r\n6.RUN\r\n\r\n7.USER\r\nUSER\u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6e\u8fd0\u884c\u5bb9\u5668\u7684UID\u3002\r\n\r\n8.WORKDIR\r\nWORKDIR\u547d\u4ee4\u7528\u4e8e\u8bbe\u7f6eCMD\u6307\u660e\u7684\u547d\u4ee4\u7684\u8fd0\u884c\u76ee\u5f55\u3002\r\n<\/pre>\n |