{"id":543,"date":"2021-11-10T10:45:06","date_gmt":"2021-11-10T02:45:06","guid":{"rendered":"https:\/\/www.djlog.cn\/?p=543"},"modified":"2021-11-19T16:48:58","modified_gmt":"2021-11-19T08:48:58","slug":"docker%e5%9f%ba%e7%a1%80%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.djlog.cn\/?p=543","title":{"rendered":"Docker\u57fa\u7840\u4f7f\u7528"},"content":{"rendered":"<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #df402a;\">1\u3001Docker \u57fa\u7840\u547d\u4ee4<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u663e\u793a\u6240\u6709\u955c\u50cf<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker ps -a<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u8fde\u63a5docker\u955c\u50cf<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker run -it IMGNAME \/bin\/bash<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u641c\u7d22\u955c\u50cf<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker search \u955c\u50cf\u540d<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u62c9\u53d6\u955c\u50cf<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker pull \u955c\u50cf\u540d<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u62c9\u53d6\u5b8c\u6210\u540e\u67e5\u770b\u955c\u50cf<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker images<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u8fd0\u884c\u955c\u50cf\uff08TAG\u662fdocker images\u547d\u4ee4\u5c55\u793a\u7684\u5217\u8868\u5b57\u6bb5\uff0c-itd\u662f\u540e\u53f0\u8fd0\u884c\uff09<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker run -itd \u955c\u50cf\u540d:TAG\u540d bash<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/ &#8211;name centos_xpmb \u4e2d\u7684 centos_xpmb \u4e3a\u955c\u50cf\u542f\u52a8\u540e\u7684\u5bb9\u5668\u540d\u79f0\uff0ccentos \u4e3a\u955c\u50cf\u540d\u79f0\uff0c\u591a\u4e2a\u7248\u672c\u53ef\u4f7f\u7528 centos:tag \u533a\u5206<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker run -itd &#8211;name centos_xpmb centos \/bin\/bash<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/ 6a55\u662fdocker ps\u67e5\u770b\u955c\u50cf\u542f\u52a8\u540e\u83b7\u5f97\u7684\u5bb9\u5668id,\u53ef\u4ee5\u53d6\u5b8c\u6574\u7684\u5bb9\u5668id<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker exec -it 6a55 bash<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u63d0\u4ea4\u955c\u50cf\u526f\u672c<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker commit -m=&#8221;ubuntu20.04\u7684\u57fa\u7840\u955c\u50cf&#8221; -a=&#8221;Test&#8221; a84ef84ce8d4 testdocker\/ubuntu_base:v1.0<\/span><\/div>\n<div>\n<ul style=\"margin: 0px;\">\n<li style=\"text-align: left; line-height: 1.75; font-size: 13px; list-style-position: inside; white-space: pre-wrap; word-break: break-word; list-style-type: disc; font-family: 'Microsoft YaHei', STXihei; color: #333333; font-weight: bold;\"><span style=\"color: #000000;\"><span style=\"background-color: #ffffff;\">-m:<\/span><span style=\"background-color: #ffffff;\">\u00a0\u63d0\u4ea4\u7684\u63cf\u8ff0\u4fe1\u606f<\/span><\/span><\/li>\n<li style=\"text-align: left; line-height: 1.75; font-size: 13px; list-style-position: inside; white-space: pre-wrap; word-break: break-word; list-style-type: disc; font-family: 'Microsoft YaHei', STXihei; color: #333333; font-weight: bold;\"><span style=\"color: #000000;\"><span style=\"background-color: #ffffff;\">-a:<\/span><span style=\"background-color: #ffffff;\">\u00a0\u6307\u5b9a\u955c\u50cf\u4f5c\u8005<\/span><\/span><\/li>\n<li style=\"text-align: left; line-height: 1.75; font-size: 13px; list-style-position: inside; white-space: pre-wrap; word-break: break-word; list-style-type: disc; font-family: 'Microsoft YaHei', STXihei; color: #333333; font-weight: bold;\"><span style=\"color: #000000;\"><span style=\"background-color: #ffffff;\">a84ef84ce8d4\uff1a<\/span><span style=\"background-color: #ffffff;\">\u5bb9\u5668 ID<\/span><\/span><\/li>\n<li style=\"text-align: left; line-height: 1.75; font-size: 13px; list-style-position: inside; white-space: pre-wrap; word-break: break-word; list-style-type: disc; font-family: 'Microsoft YaHei', STXihei; color: #333333; font-weight: bold;\"><span style=\"color: #000000;\"><span style=\"background-color: #ffffff;\">runoob\/ubuntu:v1.0 :<\/span><span style=\"background-color: #ffffff;\">\u00a0\u6307\u5b9a\u8981\u521b\u5efa\u7684\u76ee\u6807\u955c\u50cf\u540d<\/span><\/span><\/li>\n<\/ul>\n<\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u63a8\u9001\u955c\u50cf\uff08testdocker\/ubuntu_base\u4e3a\u955c\u50cf\u540d\uff09<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker push testdocker\/ubuntu_base<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u6620\u5c04\u7aef\u53e3\u53ca\u76ee\u5f55\uff0c\u5e76\u540e\u53f0\u8fd0\u884c\u5bb9\u5668 -p \u672c\u5730\u7aef\u53e3:\u5bb9\u5668\u7aef\u53e3 -v \u672c\u5730\u8def\u5f84:\u5bb9\u5668\u8def\u5f84<\/span><\/div>\n<p>&nbsp;<\/p>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">docker run -itd &#8211;name=&#8221;lnmp&#8221; -p 8081:80 -p 33061:3306 -v \/home\/www:\/home\/wwwroot\/default testdocker\/ubuntu_base \/bin\/bash<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #000000;\">\/\/\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8<\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #e03e2d;\">docker update &#8211;restart=always a84ef84ce8d4 (\u81ea\u5df1docker\u7684id) <\/span><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><\/div>\n<div style=\"white-space: pre-wrap; line-height: 1.75; font-size: 14px;\"><span style=\"color: #df402a;\">2\u3001\u914d\u7f6e\u57df\u540d\u7ed1\u5b9a<\/span><\/div>\n<div style=\"white-space: pre-wrap; text-indent: 28px; line-height: 1.75; font-size: 14px;\"><span style=\"color: #df402a;\"> 1\uff09\u5bbf\u4e3b\u673a\u914d\u7f6e\u8f6c\u53d1<\/span><\/div>\n<div style=\"white-space: pre-wrap; text-indent: 28px; line-height: 1.75; font-size: 14px; padding-left: 40px;\">\n<pre class=\"language-php\"><code>\r\nserver\r\n    {\r\n        listen 80;\r\n        server_name www.xxx.cn;\r\n        location \/ {\r\n            # \u8f6c\u53d1\u52308081\u7aef\u53e3\r\n            proxy_pass http:\/\/\u516c\u7f51IP:8081\/;\r\n            proxy_redirect off;\r\n            proxy_set_header Host $host;\r\n            proxy_set_header X - Real - IP $remote_addr;\r\n            proxy_set_header REMOTE - HOST $remote_addr;\r\n            proxy_set_header X - Forwarded - For $proxy_add_x_forwarded_for;\r\n        }\r\n        access_log\/home\/wwwlogs\/www.xxx.cn_access.log;\r\n        error_log\/home\/wwwlogs\/www.xxx.cn_error.log;\r\n    }<\/code><\/pre>\n<\/div>\n<div style=\"white-space: pre-wrap; text-indent: 28px; line-height: 1.75; font-size: 14px;\"><span style=\"color: #df402a;\"> 2\uff09docker \u5bb9\u5668\u5185 nginx \u6b63\u5e38\u914d\u7f6e\u9879\u76ee\u8bbf\u95ee\u5373\u53ef<\/span><\/div>\n<div style=\"white-space: pre-wrap; margin-left: 28px; text-indent: 28px; line-height: 1.75; font-size: 14px;\">\n<pre class=\"language-php\"><code>server\r\n    {\r\n        listen 80;\r\n        server_name www.xxx.cn;\r\n        index index.html index.htm index.php;\r\n        root  \/home\/wwwroot\/default\/;\r\n\r\n        include enable-php.conf;\r\n        location \/ {\r\n            if (!-e $request_filename) {\r\n                rewrite  ^(.*)$  \/index.php?s=\/$1  last;\r\n            }\r\n        }\r\n        location \/nginx_status\r\n        {\r\n            stub_status on;\r\n            access_log   off;\r\n        }\r\n        location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$\r\n        {\r\n            expires      30d;\r\n        }\r\n        location ~ .*\\.(js|css)?$\r\n        {\r\n            expires      12h;\r\n        }\r\n        location ~ \/\\.\r\n        {\r\n            deny all;\r\n        }\r\n        access_log  \/home\/wwwlogs\/www.xxx.cn_access.log;\r\n        error_log  \/home\/wwwlogs\/www.xxx.cn_error.log;\r\n    }<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001Docker \u57fa\u7840\u547d\u4ee4 \/\/\u663e\u793a\u6240\u6709\u955c\u50cf docker ps -a \/\/\u8fde\u63a5docker\u955c\u50cf docker [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[57],"class_list":["post-543","post","type-post","status-publish","format-standard","hentry","category-8","tag-docker"],"_links":{"self":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=543"}],"version-history":[{"count":0,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/543\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}