{"id":34898,"date":"2022-11-15T11:16:46","date_gmt":"2023-11-12T23:29:28","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/"},"modified":"2024-04-29T00:46:15","modified_gmt":"2024-04-28T16:46:15","slug":"docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/","title":{"rendered":"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86"},"content":{"rendered":"<p>\u5e08\u5085\u8bf4\uff1a\u201c\u6211\u4eec\u5728\u8fdb\u884c\u73af\u5883\u6784\u5efa\u65f6\u53ef\u4ee5\u4f7f\u7528Docker\u3002\u201d<br \/>\n\u6211\u8bf4\uff1a\u201c\u77e5\u9053\u4e86\uff01\uff01\uff01\uff08Docker&#8230;\uff1f\uff09\u201d<br \/>\n\u4e8e\u662f\u6211\u5f00\u59cb\u7814\u7a76Docker\u3002<\/p>\n<h1>Docker \u662f\u4ec0\u4e48<\/h1>\n<h2>\u4ec5\u9700\u8981\u4e00\u79cd\u9009\u62e9\uff0c\u4ee5\u4e0b\u5185\u5bb9\u7684\u4e2d\u6587\u672c\u571f\u91ca\u4e49\u5982\u4e0b\uff1a<\/h2>\n<p>Docker\u5165\u9580\uff08\u7b2c\u4e00\u56de\uff09\uff5eDocker\u3068\u306f\u4f55\u304b\u3001\u4f55\u304c\u826f\u3044\u306e\u304b\uff5e<\/p>\n<h2>\u8981\u7d04<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Docker\u306f\u3001\u30b3\u30f3\u30c6\u30ca\u578b\u306e\u4eee\u60f3\u74b0\u5883\u3092\u914d\u5e03\u30fb\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>\u4eee\u60f3\u30de\u30b7\u30f3\u3068\u306f\u9055\u3046\u3002<\/p>\n<p>\u4eee\u60f3\u30de\u30b7\u30f3<br \/>\n\u30db\u30b9\u30c8\u30de\u30b7\u30f3\u4e0a\u3067\u30cf\u30a4\u30d1\u30fc\u30d0\u30a4\u30b6\u3092\u5229\u7528\u3057\u3066\u30b2\u30b9\u30c8OS\u3092\u52d5\u304b\u3059\u3002\u305d\u306e\u3046\u3048\u3067\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306a\u3069\u3092\u52d5\u304b\u3059\u3002<br \/>\nDocker<br \/>\n\u30db\u30b9\u30c8\u30de\u30b7\u30f3\u306e\u30ab\u30fc\u30cd\u30eb\u3092\u5229\u7528\u3057\u3066\u3001\u30d7\u30ed\u30bb\u30b9\u3084\u30e6\u30fc\u30b6\u3092\u9694\u96e2\u3059\u308b\u3002\u5f93\u3063\u3066\u8efd\u91cf\u30fb\u9ad8\u901f\u3002<\/p>\n<p>\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3084\u5404\u7a2e\u74b0\u5883\u8a2d\u5b9a\u3092\u30b3\u30fc\u30c9\u5316\u3057\u3066\u7ba1\u7406\u3059\u308b\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u5316\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u5171\u6709\u3059\u308b\u3053\u3068\u3067\u3001\u3069\u3053\u3067\u3082\u8ab0\u3067\u3082\u540c\u3058\u74b0\u5883\u304c\u4f5c\u308c\u308b\u3002<br \/>\n\u4f5c\u6210\u3057\u305f\u74b0\u5883\u3092\u914d\u5e03\u3057\u3084\u3059\u3044\u3002<br \/>\n\u30b9\u30af\u30e9\u30c3\u30d7\uff06\u30d3\u30eb\u30c9\u304c\u5bb9\u6613\u306b\u3067\u304d\u308b\u3002<\/p>\n<p>Docker\u30a4\u30e1\u30fc\u30b8\u306f\u3001Web\u4e0a\u306eDocker Hub\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u3002<br \/>\nDocker\u30a4\u30e1\u30fc\u30b8\u3092\u53d6\u5f97\u3059\u308c\u3070\u3001\u3059\u3067\u306b\u5fc5\u8981\u306a\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306a\u3069\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308bDocker\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3067\u304d\u308b\u3002<\/p>\n<h2>\u6211\u7684\u5370\u8c61<\/h2>\n<p>\u4eee\u60f3\u30de\u30b7\u30f3\u3088\u308a\u8efd\u5feb\u306b\u52d5\u304f\u3089\u3057\u3044\u3002\u78ba\u304b\u306b\u4eee\u60f3\u30de\u30b7\u30f3\u3063\u3066\u3082\u3063\u3055\u308a\u3057\u3066\u3044\u308b\u5370\u8c61\u3042\u308b\u3088\u306d\u3002<br \/>\n\u300c\u30b3\u30fc\u30c9\u5316\u3057\u3066\u7ba1\u7406\u300d\u3063\u3066\u306a\u3093\u304b\u4eca\u98a8\u306a\u611f\u3058\u3002<br \/>\n\u3044\u307e\u3044\u3061\u30a4\u30e1\u30fc\u30b8\u308f\u304b\u306a\u3044\u3051\u3069\u3001\u3068\u308a\u3042\u3048\u305a\u89e6\u3063\u3066\u307f\u3088\u3046\u3002<\/p>\n<h1>Docker\u5b89\u88c5\uff0c\u542f\u52a8\u5bb9\u5668<\/h1>\n<h2>\u501f\u9274<\/h2>\n<p>Docker\u5165\u95e8\uff08\u7b2c\u4e8c\u7bc7\uff09\uff5e Docker\u5b89\u88c5\u914d\u7f6e\uff0c\u542f\u52a8\u5bb9\u5668\uff5e<\/p>\n<h2>\u5b89\u88c5Docker<\/h2>\n<p>\u8ff7\u4e0a\u4e86\u3002<br \/>\n\u4e3e\u4f8b\u6765\u8bf4\uff0c\u867d\u7136\u6211\u559c\u6b22Linux\uff0c\u4f46\u5c1d\u8bd5\u5b89\u88c5\u5728Amazon Linux2\u4e0a\u3002<br \/>\n\u65e0\u8bba\u600e\u4e48\u505a\uff0c<br \/>\nsudo amazon-linux-extras install docker<br \/>\n\u603b\u662f\u5931\u8d25\u3002<\/p>\n<pre class=\"post-pre\"><code>\u5931\u6557\u4f8b\r\n# sudo amazon-linux-extras install docker\r\nInstalling docker\r\nLoaded plugins: extras_suggestions, langpacks, priorities, update-motd\r\nCleaning repos: amzn2-core amzn2extra-docker docker-ce-stable\r\n12 metadata files removed\r\n6 sqlite files removed\r\n0 metadata files removed\r\n\uff08\u7565\uff09\r\nResolving Dependencies\r\n--&gt; Running transaction check\r\n---&gt; Package docker.x86_64 0:18.09.9ce-2.amzn2 will be installed\r\n--&gt; Processing Dependency: runc = 1.0.0 for package: docker-18.09.9ce-2.amzn2.x86_64\r\n--&gt; Processing Dependency: containerd = 1.2.6 for package: docker-18.09.9ce-2.amzn2.x86_64\r\n--&gt; Processing Dependency: pigz for package: docker-18.09.9ce-2.amzn2.x86_64\r\n--&gt; Processing Dependency: libcgroup for package: docker-18.09.9ce-2.amzn2.x86_64\r\n--&gt; Running transaction check\r\n---&gt; Package containerd.io.x86_64 0:1.2.13-3.1.el7 will be installed\r\n--&gt; Processing Dependency: container-selinux &gt;= 2:2.74 for package: containerd.io-1.2.13-3.1.el7.x86_64\r\n---&gt; Package libcgroup.x86_64 0:0.41-21.amzn2 will be installed\r\n---&gt; Package pigz.x86_64 0:2.3.4-1.amzn2.0.1 will be installed\r\n--&gt; Finished Dependency Resolution\r\nError: Package: containerd.io-1.2.13-3.1.el7.x86_64 (docker-ce-stable)\r\n           Requires: container-selinux &gt;= 2:2.74\r\n You could try using --skip-broken to work around the problem\r\n You could try running: rpm -Va --nofiles --nodigest\r\nInstallation failed. Check that you have permissions to install.\r\n<\/code><\/pre>\n<p>\u6211\u67e5\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u4e86\u8fd9\u7bc7\u6587\u7ae0\u3002<br \/>\n\u539f\u6765\u5982\u6b64\uff0c\u539f\u6765\u662f\u56e0\u4e3adocker-ce.repo\u6587\u4ef6\u7684\u95ee\u9898\u3002<br \/>\n\u4e3a\u4ec0\u4e48\u8981\u76f4\u63a5\u5f15\u7528CentOS\u7684\u6587\u7ae0\u5462\uff0c\u6211\u53cd\u7701\u3002<\/p>\n<p>\u5220\u9664\u5e76\u91cd\u65b0\u6267\u884c\u4e00\u6b21<br \/>\nsudo amazon-linux-extras install docker<br \/>\n\u5c31\u53ef\u4ee5\u4e86\u3002\u55ef\u55ef\uff0c\u6211\u77e5\u9053\u6211\u77e5\u9053\u3002<\/p>\n<h2>Docker\u3092\u52d5\u304b\u3057\u3066\u307f\u308b<\/h2>\n<h3>\u51c6\u5907\u597d\u4e86<\/h3>\n<pre class=\"post-pre\"><code>Docker\u30b5\u30fc\u30d3\u30b9\u8d77\u52d5\r\n# systemctl start docker.service\r\n\r\n\u30b5\u30fc\u30d3\u30b9\u306e\u8d77\u52d5\u78ba\u8a8d\r\n# systemctl status docker\r\n\r\nDocker\u306e\u81ea\u52d5\u8d77\u52d5\u8a2d\u5b9a\r\n# systemctl enable docker\r\n\r\n\u8a66\u3057\u306bDocker\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\r\n# docker info\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u5730\u65b9\u6ca1\u6709\u4ec0\u4e48\u95ee\u9898\uff0c\u4e00\u5207\u987a\u5229\u8fdb\u884c\u3002<\/p>\n<h3>Docker\u30a4\u30e1\u30fc\u30b8\u3068Docker\u30b3\u30f3\u30c6\u30ca<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u307e\u305a\u3001Docker\u30a4\u30e1\u30fc\u30b8\u304c\u3042\u308b\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Docker\u30a4\u30e1\u30fc\u30b8\u3092\u3082\u3068\u306b\u3001Docker\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b\u3002<\/ul>\n<h4>\u521d\u671f\u72b6\u614b<\/h4>\n<pre class=\"post-pre\"><code>\u30a4\u30e1\u30fc\u30b8\u4e00\u89a7\u3092\u8868\u793a\r\n# docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\n<\/code><\/pre>\n<p>\u521d\u671f\u72b6\u614b\u3067\u306f\u3001\u30a4\u30e1\u30fc\u30b8\u306f\u306a\u3044\u3002<br \/>\n\u5f93\u3063\u3066\u30d8\u30c3\u30c0\u30fc\u306e\u307f\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30b3\u30f3\u30c6\u30ca\u4e00\u89a7\u3092\u8868\u793a\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\r\n<\/code><\/pre>\n<p>\u30b3\u30f3\u30c6\u30ca\u3082\u8d77\u52d5\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u3001\u30d8\u30c3\u30c0\u30fc\u306e\u307f\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3002<\/p>\n<h3>\u4f7f\u7528hello-world\u955c\u50cf\u6765\u8fd0\u884c\u5bb9\u5668\u3002<\/h3>\n<pre class=\"post-pre\"><code>\u30a4\u30e1\u30fc\u30b8\u53d6\u5f97\u2192\u8d77\u52d5\r\n# docker run hello-world\r\nUnable to find image 'hello-world:latest' locally\r\nlatest: Pulling from library\/hello-world\r\n1b930d010525: Pull complete\r\nDigest: sha256:fc6a51919cfeb2e6763f62b6d9e8815acbf7cd2e476ea353743570610737b752\r\nStatus: Downloaded newer image for hello-world:latest\r\n\r\nHello from Docker!\r\nThis message shows that your installation appears to be working correctly.\r\n\r\nTo generate this message, Docker took the following steps:\r\n 1. The Docker client contacted the Docker daemon.\r\n 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\r\n    (amd64)\r\n 3. The Docker daemon created a new container from that image which runs the\r\n    executable that produces the output you are currently reading.\r\n 4. The Docker daemon streamed that output to the Docker client, which sent it\r\n    to your terminal.\r\n\r\nTo try something more ambitious, you can run an Ubuntu container with:\r\n $ docker run -it ubuntu bash\r\n\r\nShare images, automate workflows, and more with a free Docker ID:\r\n https:\/\/hub.docker.com\/\r\n\r\nFor more examples and ideas, visit:\r\n https:\/\/docs.docker.com\/get-started\/\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>\u30a4\u30e1\u30fc\u30b8\u4e00\u89a7\u3092\u8868\u793a\r\n# docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\nhello-world         latest              fce289e99eb9        14 months ago       1.84kB\r\n<\/code><\/pre>\n<p>\u786e\u8ba4\u5df2\u6dfb\u52a0\u56fe\u50cf\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30b3\u30f3\u30c6\u30ca\u4e00\u89a7\u3092\u8868\u793a\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS               NAMES\r\n24c4702a238c        hello-world         \"\/hello\"            About a minute ago   Exited (0) About a minute ago                       laughing_pascal\r\n<\/code><\/pre>\n<p>\u30b3\u30f3\u30c6\u30ca\u3082\u8d77\u52d5\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3002<br \/>\n\u300cSTAUS\u300d\u304c\u300cExited\u300d\u306b\u306a\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u6b63\u78ba\u306b\u306f\u505c\u6b62\u3057\u3066\u3044\u308b\u3002<br \/>\n\uff08hello-world\u30a4\u30e1\u30fc\u30b8\u306f\u3001MSG\u3092\u51fa\u6f01\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u505c\u6b62\u3067\u554f\u984c\u306a\u3044\u3002\uff09<\/p>\n<h3>\u5220\u9664\u955c\u50cf\u548c\u5bb9\u5668<\/h3>\n<pre class=\"post-pre\"><code>\u30b3\u30f3\u30c6\u30ca\u524a\u9664\r\n# docker rm &lt;\u30b3\u30f3\u30c6\u30ca\u540d&gt;\r\n\u3000\u3082\u3057\u304f\u306f\r\n# docker rm &lt;CONTAINER ID&gt;\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>\u30a4\u30e1\u30fc\u30b8\u4e00\u89a7\u3092\u8868\u793a\r\n# docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\nhello-world         latest              fce289e99eb9        14 months ago       1.84kB\r\n<\/code><\/pre>\n<p>\u5f62\u8c61\u5c1a\u672a\u6d88\u5931\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30b3\u30f3\u30c6\u30ca\u4e00\u89a7\u3092\u8868\u793a\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\r\n<\/code><\/pre>\n<p>\u96c6\u88c5\u7bb1\u5df2\u7ecf\u6d88\u5931\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30a4\u30e1\u30fc\u30b8\u524a\u9664\r\n# docker rmi &lt;\u30a4\u30e1\u30fc\u30b8\u540d&gt;\r\n\u3000\u3082\u3057\u304f\u306f\r\n# docker rmi &lt;IMAGE ID&gt;\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>\u30a4\u30e1\u30fc\u30b8\u4e00\u89a7\u3092\u8868\u793a\r\n# docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\n<\/code><\/pre>\n<p>\u5f62\u8c61\u4e5f\u6d88\u5931\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30b3\u30f3\u30c6\u30ca\u4e00\u89a7\u3092\u8868\u793a\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\r\n<\/code><\/pre>\n<p>\u5f53\u7136\uff0c\u5bb9\u5668\u5df2\u7ecf\u6d88\u5931\u4e86\u3002<\/p>\n<h3>\u4f7f\u7528Nginx\u56fe\u50cf<\/h3>\n<pre class=\"post-pre\"><code>Nginx\u30a4\u30e1\u30fc\u30b8\u306e\u53d6\u5f97\r\n# docker pull nginx\r\nUsing default tag: latest\r\nlatest: Pulling from library\/nginx\r\n68ced04f60ab: Pull complete\r\nc4039fd85dcc: Pull complete\r\nc16ce02d3d61: Pull complete\r\nDigest: ***\r\nStatus: Downloaded newer image for nginx:latest\r\n\r\nNginx\u30b3\u30f3\u30c6\u30ca\u306e\u8d77\u52d5\r\n# docker run -d --name nginx-container -p 8181:80 nginx\r\n<\/code><\/pre>\n<p>\u542f\u52a8\u9009\u9879\u5982\u4e0b\u3002<\/p>\n<div>\n<div class=\"post-table\">\u30aa\u30d7\u30b7\u30e7\u30f3\u610f\u5473-d\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u5b9f\u884c&#8211;name &lt;\u4efb\u610f\u306e\u540d\u524d&gt;\u30b3\u30f3\u30c6\u30ca\u540d\u3092\u6307\u5b9a-p &lt;\u30db\u30b9\u30c8\u5074\u306ePORT&gt;:&lt;\u30b3\u30f3\u30c6\u30ca\u5074\u306ePORT&gt;PORT\u3092\u6307\u5b9a<\/div>\n<\/div>\n<p>\u53ea\u9700\u8981\u4e00\u4e2a\u9009\u9879\u6765\u7528\u4e2d\u6587\u672c\u5730\u5316\u5730\u6539\u5199\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>\u901a\u8fc7http:\/\/&lt;\u670d\u52a1\u5668IP&gt;:8181\/\u53ef\u4ee5\u8bbf\u95eeNginx\u3002<br \/>\n\uff08\u5982\u679c\u662fEC2\u670d\u52a1\u5668\uff0c\u9700\u8981\u66f4\u6539\u5b89\u5168\u7ec4\u8bbe\u7f6e\uff09<\/p>\n<h1>\u6709\u5173Docker\u547d\u4ee4\u7684\u5185\u5bb9<\/h1>\n<h2>\u8bf7\u53c2\u8003<\/h2>\n<p>Docker\u5165\u95e8\uff08\u7b2c\u4e09\u90e8\uff09- Docker\u547d\u4ee4\u548cDocker\u955c\u50cf\u521b\u5efa\u7684\u5404\u79cd\u64cd\u4f5c<\/p>\n<h2>\u4f7f\u7528\u4e0d\u540c\u7684\u6307\u4ee4\u9032\u884c\u64cd\u4f5c\u3002<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Docker\u30a4\u30e1\u30fc\u30b8\u53d6\u5f97\u3001\u30a4\u30e1\u30fc\u30b8\u4e00\u89a7\u78ba\u8a8d<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u3001\u30b3\u30f3\u30c6\u30ca\u4e00\u89a7\u78ba\u8a8d<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b3\u30f3\u30c6\u30ca\u3078\u306e\u30ed\u30b0\u30a4\u30f3<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30a1\u30a4\u30eb\u30b3\u30d4\u30fc(\u30db\u30b9\u30c8\u2192\u30b3\u30f3\u30c6\u30ca\u5185)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30a1\u30a4\u30eb\u30b3\u30d4\u30fc(\u30b3\u30f3\u30c6\u30ca\u5185\u2192\u30db\u30b9\u30c8)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b3\u30f3\u30c6\u30ca\u304b\u3089Docker\u30a4\u30e1\u30fc\u30b8\u4f5c\u6210<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u3001\u505c\u6b62<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30b3\u30f3\u30c6\u30ca\u524a\u9664<\/ul>\n<p>\u53ea\u9700\u53c2\u8003\u94fe\u63a5\u5373\u53ef\u7701\u7565\u3002<\/p>\n<h2>\u30db\u30b9\u30c8\u5074\u3068\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5171\u6709<\/h2>\n<p>\u8d77\u52d5\u6642\u306bv\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u308b\u3053\u3068\u3067\u3001\u30db\u30b9\u30c8\u5074\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u30b3\u30f3\u30c6\u30ca\u5185\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u5171\u6709\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3002<br \/>\n\u4f7f\u7528\u4f8b\u3068\u3057\u3066\u306f\u3001\u30ed\u30b0\u306e\u51fa\u529b\u5148\u306a\u3069\u3002<br \/>\n\u4f8b\u3048\u3070\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u30ed\u30b0\u3092\u51fa\u529b\u3057\u3066\u3044\u305f\u5834\u5408\u3001\u30b3\u30f3\u30c6\u30ca\u306e\u505c\u6b62\u3068\u3068\u3082\u306b\u6d88\u3048\u3066\u3057\u307e\u3046\u305f\u3081\u3002<\/p>\n<div>\n<div class=\"post-table\">\u30aa\u30d7\u30b7\u30e7\u30f3\u610f\u5473-v &lt;\u30db\u30b9\u30c8\u5074\u30c7\u30a3\u30ec\u30af\u30c8\u30ea&gt;:&lt;\u30b3\u30f3\u30c6\u30ca\u5074\u30c7\u30a3\u30ec\u30af\u30c8\u30ea&gt;\u4e21\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u5171\u6709\u306b\u3059\u308b<\/div>\n<\/div>\n<pre class=\"post-pre\"><code>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5171\u6709\u3057\u305f\u72b6\u614b\u3067\u8d77\u52d5\r\n# docker run -it -d -p 18080:8080 -v \/root\/tomcat-container\/logs:\/share\/logs --name tomcat centos:7\r\n<\/code><\/pre>\n<h2>\u521b\u9020\u56fe\u50cf<\/h2>\n<p>\u867d\u7136\u8fc4\u4eca\u4e3a\u6b62\u6211\u4eec\u662f\u901a\u8fc7\u60f3\u8c61\u6765\u521b\u5efa\u5bb9\u5668\uff0c\u4f46\u4e5f\u53ef\u4ee5\u4ece\u5bb9\u5668\u4e2d\u521b\u5efa\u5f71\u50cf\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30b3\u30f3\u30c6\u30ca\u306e\u505c\u6b62\uff08\u3084\u3089\u306a\u304f\u3066\u3082\u4f5c\u6210\u3067\u304d\u308b\u307f\u305f\u3044\u3002\u505c\u6b62\u3057\u305f\u307b\u3046\u304c\u5b89\u5168\uff1f\uff09\r\n# docker stop nginx-container\r\n\r\nnginx-container\u30b3\u30f3\u30c6\u30ca\u304b\u3089\u3001nginx2\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\r\n# docker commit nginx-container nginx_2\r\n\r\n\u30a4\u30e1\u30fc\u30b8\u3092\u78ba\u8a8d\r\n# docker images\r\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\nnginx_2             latest              4a4ce52ad449        6 seconds ago       127MB\r\nnginx               latest              a1523e859360        6 days ago          127MB\r\n<\/code><\/pre>\n<p>\u8bd5\u7740\u4ece\u521b\u5efa\u7684nginx_2\u955c\u50cf\u4e2d\u542f\u52a8\u5bb9\u5668\u3002<\/p>\n<pre class=\"post-pre\"><code>Nginx_2\u30b3\u30f3\u30c6\u30ca\u306e\u8d77\u52d5\r\n# docker run -d --name nginx2-container -p 8182:80 nginx_2\r\n\r\n\u8d77\u52d5\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u306e\u78ba\u8a8d\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES\r\n53e414bab96d        nginx_2             \"nginx -g 'daemon of\u2026\"   41 seconds ago      Up 39 seconds       0.0.0.0:8182-&gt;80\/tcp   nginx2-container\r\n4e29184909ff        nginx               \"nginx -g 'daemon of\u2026\"   29 hours ago        Up 29 minutes       0.0.0.0:8181-&gt;80\/tcp   nginx-container\r\n\r\n\u78ba\u8a8d\u3067\u304d\u305f\u306e\u3067\u6b62\u3081\u308b\r\n# docker stop nginx2-container\r\n\r\n\u505c\u6b62\u306e\u78ba\u8a8d\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                  NAMES\r\n53e414bab96d        nginx_2             \"nginx -g 'daemon of\u2026\"   2 minutes ago       Exited (0) 9 seconds ago                          nginx2-container\r\n4e29184909ff        nginx               \"nginx -g 'daemon of\u2026\"   29 hours ago        Up 31 minutes              0.0.0.0:8181-&gt;80\/tcp   nginx-container\r\n\r\n\u30b3\u30f3\u30c6\u30ca\u306e\u524a\u9664\r\n# docker rm nginx2-container\r\n\r\n\u524a\u9664\u306e\u78ba\u8a8d\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES\r\n4e29184909ff        nginx               \"nginx -g 'daemon of\u2026\"   29 hours ago        Up 31 minutes       0.0.0.0:8181-&gt;80\/tcp   nginx-container\r\n<\/code><\/pre>\n<h1>\u5173\u4e8eDockefile\u7684\u95ee\u9898<\/h1>\n<h2>\u8bf7\u53c2\u7167\u4e0b\u5217\u9009\u9879\u4e2d\u7684\u4e00\u9879\u4ee5\u4e2d\u6587\u8fdb\u884c\u6539\u8ff0\uff1a<\/h2>\n<p>Docker\u57fa\u7840\uff08\u7b2c\u56db\u7ae0\uff09\uff5e\u5173\u4e8eDockerfile\uff5e<\/p>\n<h2>Dockerfile \u662f\u4ec0\u4e48\uff1f<\/h2>\n<p>\u516c\u958b\u3055\u308c\u3066\u3044\u308bDocker\u30a4\u30e1\u30fc\u30b8\u306b\u3001\u300c\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3084\u30a2\u30d7\u30ea\u3092\u8ffd\u52a0\u3059\u308b\u300d\u300c\u5404\u7a2e\u8a2d\u5b9a\u3092\u3059\u308b\u300d\u306a\u3069\u5c11\u3057\u624b\u3092\u52a0\u3048\u3066\u304a\u304d\u305f\u3044\u5834\u5408\u306b\u4f7f\u7528\u3059\u308b\u3082\u306e\u3002<br \/>\nDockerfile\u5185\u306b\u3001\u5b9f\u884c\u3057\u305f\u3044\u5185\u5bb9\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<h2>\u5c1d\u8bd5\u4f7f\u7528Dockerfile\u3002<\/h2>\n<p>\u2026\u3068\u601d\u3063\u305f\u3051\u3069\u3001\u53c2\u8003\u8a18\u4e8b\u306e\u4f8b\u306ftomcat\u3060\u3057\u3061\u3087\u3063\u3068\u5fae\u5999\u304b\u306a\u3068\u3002<br \/>\n\u3069\u3046\u305b\u306a\u3089Laravel\u74b0\u5883\u4f5c\u6210\u3057\u305f\u308a\u3057\u305f\u3044\u306a\u3068\u3002<\/p>\n<p>\u305d\u3093\u306a\u3053\u3068\u3092\u601d\u3063\u3066\u305f\u3089\u3053\u3093\u306a\u3082\u306e\u304c\u3042\u3063\u305f\u3002<br \/>\nDocker\u3092\u4f7f\u3063\u3066Laravel\u958b\u767a\u74b0\u5883\u69cb\u7bc9<br \/>\n\u6700\u9ad8\u3063\u3059\u3002\u30c9\u30f3\u30d4\u30b7\u30e3\u3063\u3059\u3002<br \/>\n\u3068\u3044\u3046\u308f\u3051\u3067\u3001\u5b9f\u969b\u306b\u52d5\u304b\u3059\u306e\u306f\u5225\u306e\u6a5f\u4f1a\u306b\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<h1>\u5173\u4e8e\u5bb9\u5668\u4e4b\u95f4\u901a\u4fe1\u7684\u95ee\u9898<\/h1>\n<h2>\u8bf7\u63d0\u4f9b\u66f4\u5177\u4f53\u7684\u5185\u5bb9\u4ee5\u4fbf\u51c6\u786e\u56de\u7b54\u3002<\/h2>\n<p>Docker\u5165\u95e8\uff08\u7b2c\u4e94\u8282\uff09- \u5bb9\u5668\u4e4b\u95f4\u7684\u901a\u4fe1<\/p>\n<h2>\u5bb9\u5668\u95f4\u901a\u4fe1<\/h2>\n<p>\u8981\u8ba9\u5bb9\u5668\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\uff0c\u6709\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a<br \/>\n1. \u521b\u5efaDocker\u7f51\u7edc\uff0c\u5e76\u901a\u8fc7\u5bb9\u5668\u540d\u79f0\u8fdb\u884c\u8fde\u63a5\u3002<br \/>\n2. \u4f7f\u7528&#8211;link\u9009\u9879\u542f\u52a8\u5bb9\u5668\u3002<\/p>\n<h3>\u521b\u5efaDocker\u7f51\u7edc<\/h3>\n<p>\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2aDocker\u7f51\u7edc\uff08\u6865\u63a5\u7c7b\u578b\uff09\u3002<br \/>\n\u6709\u5173\u5176\u4ed6\u7c7b\u578b\uff0c\u8bf7\u53c2\u9605\u8fd9\u91cc\u3002<\/p>\n<pre class=\"post-pre\"><code>\u300cnetwork1\u300d\u3068\u3044\u3046Docker\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u4f5c\u6210\r\n# docker network create network1\r\n\r\nDocker\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u4e00\u89a7\u3092\u8868\u793a\r\n# docker network ls\r\nNETWORK ID          NAME                DRIVER              SCOPE\r\n064b0ea3a75c        bridge              bridge              local\r\n7281bec71e9e        host                host                local\r\n3585fc587596        network1            bridge              local\r\n272c5bc211eb        none                null                local\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u786e\u8ba4\u5b58\u5728\u300cnetwork1\u300d\u3002<br \/>\n\u867d\u7136\u9ed8\u8ba4\u5b58\u5728\u300cbridge\u300d\uff0c\u4f46\u7531\u4e8e\u672a\u8fdb\u884c DNS \u8bbe\u7f6e\u65e0\u6cd5\u89e3\u6790\u540d\u79f0\uff0c\u4f3c\u4e4e\u65e0\u6cd5\u4f7f\u7528\u5bb9\u5668\u540d\u79f0\u8fdb\u884c\u5bb9\u5668\u95f4\u901a\u4fe1\u3002<\/p>\n<pre class=\"post-pre\"><code>Docker\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8a73\u7d30\u3092\u8868\u793a\r\n# docker network inspect network1\r\n[\r\n    {\r\n        \"Name\": \"network1\",\r\n        \"Id\": \"3585fc587596ba17195364d8aea2e77add0978813782bfb21b15486153df109c\",\r\n        \"Created\": \"2020-03-04T17:38:12.168101241Z\",\r\n        \"Scope\": \"local\",\r\n        \"Driver\": \"bridge\",\r\n        \"EnableIPv6\": false,\r\n        \"IPAM\": {\r\n            \"Driver\": \"default\",\r\n            \"Options\": {},\r\n            \"Config\": [\r\n                {\r\n                    \"Subnet\": \"172.18.0.0\/16\",\r\n                    \"Gateway\": \"172.18.0.1\"\r\n                }\r\n            ]\r\n        },\r\n        \"Internal\": false,\r\n        \"Attachable\": false,\r\n        \"Ingress\": false,\r\n        \"ConfigFrom\": {\r\n            \"Network\": \"\"\r\n        },\r\n        \"ConfigOnly\": false,\r\n        \"Containers\": {},\r\n        \"Options\": {},\r\n        \"Labels\": {}\r\n    }\r\n]\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>\u300cnetwork1\u300d\u3092\u4f7f\u7528\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u6210\r\n# docker run -d --name nginx3-container --network network1 -p 8183:80 nginx_2\r\n\r\n\u8d77\u52d5\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u3092\u78ba\u8a8d\r\n# docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES\r\n20158137a4ce        nginx_2             \"nginx -g 'daemon of\u2026\"   3 seconds ago       Up 1 second         0.0.0.0:8183-&gt;80\/tcp   nginx3-container\r\n1487009fb41a        nginx_2             \"nginx -g 'daemon of\u2026\"   12 minutes ago      Up 12 minutes       0.0.0.0:8182-&gt;80\/tcp   nginx2-container\r\n4e29184909ff        nginx               \"nginx -g 'daemon of\u2026\"   35 hours ago        Up 6 hours          0.0.0.0:8181-&gt;80\/tcp   nginx-container\r\n<\/code><\/pre>\n<p>\u82e5\u8981\u8fdb\u884c\u5bb9\u5668\u4e4b\u95f4\u7684\u901a\u4fe1\uff0c\u8bf7\u6307\u5b9a\u5bb9\u5668\u5185\u90e8\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002<\/p>\n<p>\u5982\u679c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efaMySQL\u5bb9\u5668\uff0c\u4e3b\u673a\u7aef\u53e3\u5c06\u4e3a19090\uff0c\u5bb9\u5668\u5185\u7aef\u53e3\u5c06\u4e3a9090\u3002<\/p>\n<pre class=\"post-pre\"><code># docker run --name mysql --network wordpress-network -p 19090:9090 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7\r\n<\/code><\/pre>\n<p>\u3053\u306e\u5834\u5408\u3001\u30b3\u30f3\u30c6\u30ca\u9593\u901a\u4fe1\u3067\u6307\u5b9a\u3059\u308bPORT\u306f\u300c9090\u300d\u3068\u306a\u308b\u3002<\/p>\n<h3>\u901a\u8fc7\u94fe\u63a5\u9009\u9879\u8fdb\u884c\u901a\u4fe1<\/h3>\n<pre class=\"post-pre\"><code>\u3042\u3089\u304b\u3058\u3081\u3001mysql\u30b3\u30f3\u30c6\u30ca\u3092\u300csome-mysql\u300d\u3068\u3044\u3046\u540d\u524d\u3067\u4f5c\u6210\r\n# docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7\r\n\r\n--link\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u7528\u3044\u3066\u300csome-mysql:mysql\uff08wordpress\u30b3\u30f3\u30c6\u30ca\u5185\u3067\u4f7f\u7528\u3057\u3066\u3044\u308bMySQL\u306e\u30db\u30b9\u30c8\u540d\uff09\u300d\u3092\u6307\u5b9a\r\n# docker run --name some-wordpress -e WORDPRESS_DB_PASSWORD=my-secret-pw --link some-mysql:mysql -d -p 8080:80 wordpress\r\n<\/code><\/pre>\n<h1>\u5173\u4e8eDocker Compose<\/h1>\n<h2>\u8bf7\u63d0\u4f9b\u66f4\u5177\u4f53\u7684\u5185\u5bb9\u6216\u53e5\u5b50\u8fdb\u884c\u7ffb\u8bd1\u3002<\/h2>\n<p>Docker\u5165\u9580\uff08\u7b2c\u516d\u8282\uff09- Docker Compose<\/p>\n<h2>Docker Compose \u662f\u4ec0\u4e48\uff1f<\/h2>\n<blockquote><p>Docker Compose\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u4e8e\u66f4\u65b9\u4fbf\u5730\u5bf9\u7531\u591a\u4e2a\u5bb9\u5668\u7ec4\u6210\u7684\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884cDocker\u955c\u50cf\u6784\u5efa\u4ee5\u53ca\u5404\u4e2a\u5bb9\u5668\u7684\u542f\u52a8\u548c\u505c\u6b62\u7b49\u64cd\u4f5c\u3002<\/p><\/blockquote>\n<p>\u53ef\u4ee5\u540c\u65f6\u542f\u52a8\u591a\u4e2a\u5bb9\u5668\uff0c\u4e5f\u53ef\u4ee5\u9009\u62e9\u7701\u7565\u9009\u9879\u7684\u4e1c\u897f\uff08\uff1f\uff09<\/p>\n<h2>Docker Compose\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<pre class=\"post-pre\"><code>Docker\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u74b0\u5883\u3067\u4ee5\u4e0b\u3092\u5b9f\u884c\r\n# curl -L https:\/\/github.com\/docker\/compose\/releases\/download\/1.21.2\/docker-compose-$(uname -s)-$(uname -m) -o \/usr\/local\/bin\/docker-compose\r\n# chmod +x \/usr\/local\/bin\/docker-compose\r\n\r\nDocker Compose\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u78ba\u8a8d\r\n# docker-compose --version\r\ndocker-compose version 1.21.2, build a133471\r\n<\/code><\/pre>\n<h2>\u5173\u4e8edocker-compose.yml<\/h2>\n<p>Docker Compose\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u300cdocker-compose.yml\u300d\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981\u3068\u306a\u308b\u3002<br \/>\n\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u60c5\u5831\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n&#8211; Docker\u30a4\u30e1\u30fc\u30b8\u3092\u30d3\u30eb\u30c9\u3059\u308b\u305f\u3081\u306e\u60c5\u5831\uff08\u4f7f\u7528\u3059\u308bDockerfile\u3001\u30a4\u30e1\u30fc\u30b8\u540d\u306a\u3069\uff09<br \/>\n&#8211; \u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u3059\u308b\u305f\u3081\u306e\u60c5\u5831\uff08\u30db\u30b9\u30c8\u3068\u306e\u5171\u6709\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8a2d\u5b9a\u3084\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u8d77\u52d5\u30aa\u30d7\u30b7\u30e7\u30f3\u306a\u3069\uff09<br \/>\n&#8211; \u4f7f\u7528\u3059\u308bDocker\u30cd\u30c3\u30c8\u30ef\u30fc\u30af<\/p>\n<p>\u4f7f\u7528run\u547d\u4ee4\u542f\u52a8MySQL\u548cWordPress\u5bb9\u5668<\/p>\n<pre class=\"post-pre\"><code># docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.7\r\n# docker run --name some-wordpress -e WORDPRESS_DB_PASSWORD=my-secret-pw --link some-mysql:mysql -d -p 8080:80 wordpress\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5c06\u8fd9\u4e2a\u5199\u5165\u5230&#8221;docker-compose.yml&#8221;\u6587\u4ef6\u4e2d\uff0c\u5c31\u50cf\u4e0b\u9762\u8fd9\u6837\u3002<\/p>\n<pre class=\"post-pre\"><code>version: '3'\r\nservices:\r\n\r\n  wordpress:\r\n    image: wordpress\r\n    container_name: some-wordpress\r\n    restart: always\r\n    ports:\r\n      - 8080:80\r\n    environment:\r\n      WORDPRESS_DB_PASSWORD: my-secret-pw\r\n\r\n  mysql:\r\n    image: mysql:5.7\r\n    container_name: some-mysql\r\n    restart: always\r\n    environment:\r\n      MYSQL_ROOT_PASSWORD: my-secret-pw\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528\u81ea\u5df1\u521b\u5efa\u7684\uff08\u975e\u516c\u5f00\uff09Docker\u955c\u50cf\uff08\u4f8b\u5982\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>version: '3'\r\nservices:\r\n  tomcat:\r\n    build: .\/tomcat\r\n    image: tomcat-image\r\n    container_name: tomcat1\r\n    ports:\r\n      - 8081:8080\r\n    volumes:\r\n      - .\/tomcat\/share\/logs:\/share\/logs\r\n<\/code><\/pre>\n<p>run\u30b3\u30de\u30f3\u30c9\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u300cdocker-compose.yml\u300d\u306e\u8a18\u8f09\u5185\u5bb9\u3092\u6bd4\u8f03\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u901a\u308a\u3002<\/p>\n<div>\n<div class=\"post-table\">\u8a2d\u5b9a\u5185\u5bb9run\u30b3\u30de\u30f3\u30c9\u306e\u30aa\u30d7\u30b7\u30e7\u30f3docker-compose.yml\u30b3\u30f3\u30c6\u30ca\u540d&#8211;namecontainer_name\u74b0\u5883\u5909\u6570-eenvironment\u30dd\u30fc\u30c8\u30d5\u30a9\u30ef\u30fc\u30c9-pports\u4f7f\u7528\u3059\u308bDocker\u30a4\u30e1\u30fc\u30b8\u30b3\u30de\u30f3\u30c9\u306e\u6700\u5f8cimageDockerfile\u306e\u6307\u5b9adocker build\u30b3\u30de\u30f3\u30c9build\u5171\u6709\u30c7\u30a3\u30ec\u30af\u30c8\u30ea-vvolumes:<\/div>\n<\/div>\n<p>\u300c&#8211;link\u300d\u30aa\u30d7\u30b7\u30e7\u30f3\u306b\u5bfe\u5fdc\u3059\u308b\u3082\u306e\u306f\u306a\u3044\u304c\u3001\u305d\u3082\u305d\u3082\u300cdocker-compose.yml\u300d\u3092\u4f7f\u7528\u3057\u305f\u5834\u5408\u306f\u81ea\u52d5\u3067Docker\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u3001\u81ea\u52d5\u3067service\u540d\u3067\u540d\u524d\u89e3\u6c7a\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<p>\u300cdocker-compose.yml\u300d\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<pre class=\"post-pre\"><code># cd &lt;docker-compose.yml\u304c\u7f6e\u304b\u308c\u3066\u3044\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea&gt;\r\n\r\ndocker-compose\u306b\u3088\u308b\u8d77\u52d5\r\n# docker-compose up -d\r\n\r\n\u8d77\u52d5\u306e\u78ba\u8a8d\r\n# docker-commpose ps\r\nName                   Command               State          Ports\r\n------------------------------------------------------------------------------\r\nsome-mysql       docker-entrypoint.sh mysqld      Up      3306\/tcp, 33060\/tcp\r\nsome-wordpress   docker-entrypoint.sh apach ...   Up      0.0.0.0:8080-&gt;80\/tcp\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c1d\u8bd5\u6784\u5efaLaravel\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5e08\u5085\u8bf4\uff1a\u201c\u6211\u4eec\u5728\u8fdb\u884c\u73af\u5883\u6784\u5efa\u65f6\u53ef\u4ee5\u4f7f\u7528Docker\u3002\u201d \u6211\u8bf4\uff1a\u201c\u77e5\u9053\u4e86\uff01\uff01\uff01\uff08Docker&#8230;\uff1f\uff09\u201d [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-34898","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86\" \/>\n<meta property=\"og:description\" content=\"\u5e08\u5085\u8bf4\uff1a\u201c\u6211\u4eec\u5728\u8fdb\u884c\u73af\u5883\u6784\u5efa\u65f6\u53ef\u4ee5\u4f7f\u7528Docker\u3002\u201d \u6211\u8bf4\uff1a\u201c\u77e5\u9053\u4e86\uff01\uff01\uff01\uff08Docker&#8230;\uff1f\uff09\u201d [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-12T23:29:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T16:46:15+00:00\" \/>\n<meta name=\"author\" content=\"\u65b0, \u97f5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u65b0, \u97f5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/\",\"name\":\"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-11-12T23:29:28+00:00\",\"dateModified\":\"2024-04-28T16:46:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9\",\"name\":\"\u65b0, \u97f5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g\",\"caption\":\"\u65b0, \u97f5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunxin\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86","og_description":"\u5e08\u5085\u8bf4\uff1a\u201c\u6211\u4eec\u5728\u8fdb\u884c\u73af\u5883\u6784\u5efa\u65f6\u53ef\u4ee5\u4f7f\u7528Docker\u3002\u201d \u6211\u8bf4\uff1a\u201c\u77e5\u9053\u4e86\uff01\uff01\uff01\uff08Docker&#8230;\uff1f\uff09\u201d [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-11-12T23:29:28+00:00","article_modified_time":"2024-04-28T16:46:15+00:00","author":"\u65b0, \u97f5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u65b0, \u97f5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/","name":"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-11-12T23:29:28+00:00","dateModified":"2024-04-28T16:46:15+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Docker\u6211\u5f00\u59cb\u4f7f\u7528\u4e86"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/4ba4019495123db3038fd0809e6959c9","name":"\u65b0, \u97f5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d484b6c6e4ae82e8a9efea989e1d2af46d9b6ef128101e63b18f559fca0ae627?s=96&d=mm&r=g","caption":"\u65b0, \u97f5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yunxin\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/docker%e6%88%91%e5%bc%80%e5%a7%8b%e4%bd%bf%e7%94%a8%e4%ba%86%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=34898"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34898\/revisions"}],"predecessor-version":[{"id":69336,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/34898\/revisions\/69336"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=34898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=34898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=34898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}