{"id":142,"date":"2020-10-29T12:00:51","date_gmt":"2020-10-29T04:00:51","guid":{"rendered":"https:\/\/www.92k.xin\/?p=142"},"modified":"2020-10-29T12:21:51","modified_gmt":"2020-10-29T04:21:51","slug":"centos7%e4%b8%8b%e5%bc%80%e5%90%afdocker%e5%85%a5%e9%97%a8%e7%af%87","status":"publish","type":"post","link":"https:\/\/www.92k.xin\/?p=142","title":{"rendered":"CENTOS7\u4e0b\u5f00\u542fDocker(\u5165\u95e8\u7bc7)"},"content":{"rendered":"\n

CENTOS7\u4e0b\u5f00\u542fDocker,CenterOS7\u5b89\u88c5docker\u8981\u6c42\u5185\u6838\u7248\u672c\u57283.10\u4ee5\u4e0a(uname -r)<\/p>\n\n\n\n

yum install docker<\/p>\n\n\n\n

<\/div>\n\n\n\n
<\/div>\n\n\n\n

\u542f\u52a8docker<\/p>\n\n\n\n

systemctl start docker<\/p>\n\n\n\n

\u7248\u672c\u67e5\u770b<\/p>\n\n\n\n

docker version<\/p>\n\n\n\n

\"%title\u63d2\u56fe%num\"
docker version \u542f\u52a8\u548c\u505c\u6b62\u65f6\u5019\u663e\u793a\u4e0d\u4e00\u6837<\/figcaption><\/figure>\n\n\n\n

\u72b6\u6001\u67e5\u770b systemctl status docker<\/p>\n\n\n\n

\u25cf docker.service - Docker Application Container Engine\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/docker.service; disabled; vendor preset: disabled)\n   Active: active (running) since \u56db 2020-10-29 10:44:33 CST; 8s ago\n     Docs: http:\/\/docs.docker.com\n Main PID: 6096 (dockerd-current)\n   CGroup: \/system.slice\/docker.service\n           \u251c\u25006096 \/usr\/bin\/dockerd-current --add-runtime docker-runc=\/usr\/libexec\/docker\/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdrive\n           \u2514\u25006107 \/usr\/bin\/docker-containerd-current -l unix:\/\/\/var\/run\/docker\/libcontainerd\/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir \n\n10\u6708 29 10:44:32 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:32.133897123+08:00\" level=info msg=\"libcontainerd: new containerd process, pid: 6107\"\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.511531824+08:00\" level=info msg=\"Graph migration to content-addressability took 0.00 seco\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.514168291+08:00\" level=info msg=\"Loading containers: start.\"\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.532101146+08:00\" level=info msg=\"Firewalld running: true\"\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.747994444+08:00\" level=info msg=\"Default bridge (docker0) is assigned with an IP address \n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.865758833+08:00\" level=info msg=\"Loading containers: done.\"\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.929515913+08:00\" level=info msg=\"Daemon has completed initialization\"\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.929568648+08:00\" level=info msg=\"Docker daemon\" commit=\"64e9980\/1.13.1\" graphdriver=overl\n10\u6708 29 10:44:33 vip1.92k.xin dockerd-current[6096]: time=\"2020-10-29T10:44:33.953292472+08:00\" level=info msg=\"API listen on \/var\/run\/docker.sock\"\n10\u6708 29 10:44:33 vip1.92k.xin systemd[1]: Started Docker Application Container Engine.<\/pre><\/div>\n\n\n\n

docker \u56fd\u5185\u52a0\u901f,\u8fd9\u91cc\u5176\u5b9e\u6539\u53d8\u7684\u5c31\u662f \u4ed3\u5e93 \u7684\u4f4d\u7f6e<\/strong><\/span>\u3002<\/p>\n\n\n\n

\u7f16\u8f91 \/etc\/docker\/deamon.json,\u7136\u540e\u91cd\u542f docker\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n

{\n  \"registry-mirrors\": [\"http:\/\/hub-mirror.c.163.com\", \"https:\/\/registry.docker-cn.com\"]\n}<\/pre><\/div>\n\n\n\n

\u4e0b\u9762\u6211\u4eec\u6765\u7528docker\u6765\u542f\u7528\u4e00\u4e2anginx<\/p>\n\n\n\n

<\/div>\n\n\n\n

\u9996\u5148\u6211\u4eec\u9700\u8981\u67e5\u627enginx\u7684\u955c\u50cf(\u4ece\u4ed3\u5e93\u91cc\u9762\u67e5\u627e\u955c\u50cf<\/span><\/strong>) docker search nginx<\/p>\n\n\n\n

INDEX       NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED\ndocker.io   docker.io\/nginx                              Official build of Nginx.                        13930     [OK]       \ndocker.io   docker.io\/jwilder\/nginx-proxy                Automated Nginx reverse proxy for docker c...   1901                 [OK]\ndocker.io   docker.io\/richarvey\/nginx-php-fpm            Container running Nginx + PHP-FPM capable ...   791                  [OK]\ndocker.io   docker.io\/linuxserver\/nginx                  An Nginx container, brought to you by Linu...   128                  \ndocker.io   docker.io\/jc21\/nginx-proxy-manager           Docker container for managing Nginx proxy ...   103                  \ndocker.io   docker.io\/tiangolo\/nginx-rtmp                Docker image with Nginx using the nginx-rt...   99                   [OK]\ndocker.io   docker.io\/bitnami\/nginx                      Bitnami nginx Docker Image                      90                   [OK]\ndocker.io   docker.io\/alfg\/nginx-rtmp                    NGINX, nginx-rtmp-module and FFmpeg from s...   78                   [OK]\ndocker.io   docker.io\/jlesage\/nginx-proxy-manager        Docker container for Nginx Proxy Manager        64                   [OK]\ndocker.io   docker.io\/nginxdemos\/hello                   NGINX webserver that serves a simple page ...   62                   [OK]\ndocker.io   docker.io\/nginx\/nginx-ingress                NGINX Ingress Controller for Kubernetes         43                   \ndocker.io   docker.io\/privatebin\/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & ...   39                   [OK]\ndocker.io   docker.io\/nginxinc\/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  19                   \ndocker.io   docker.io\/schmunk42\/nginx-redirect           A very simple container to redirect HTTP t...   19                   [OK]\ndocker.io   docker.io\/centos\/nginx-112-centos7           Platform for running nginx 1.12 or buildin...   15                   \ndocker.io   docker.io\/nginx\/nginx-prometheus-exporter    NGINX Prometheus Exporter                       15                   \ndocker.io   docker.io\/centos\/nginx-18-centos7            Platform for running nginx 1.8 or building...   13                   \ndocker.io   docker.io\/raulr\/nginx-wordpress              Nginx front-end for the official wordpress...   13                   [OK]\ndocker.io   docker.io\/staticfloat\/nginx-certbot          Opinionated setup for automatic TLS certs ...   13                   [OK]\ndocker.io   docker.io\/bitwarden\/nginx                    The Bitwarden nginx web server acting as a...   7                    \ndocker.io   docker.io\/mailu\/nginx                        Mailu nginx frontend                            7                    [OK]\ndocker.io   docker.io\/sophos\/nginx-vts-exporter          Simple server that scrapes Nginx vts stats...   7                    [OK]\ndocker.io   docker.io\/bitnami\/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Con...   6                    [OK]\ndocker.io   docker.io\/ansibleplaybookbundle\/nginx-apb    An APB to deploy NGINX                          1                    [OK]\ndocker.io   docker.io\/wodby\/nginx                        Generic nginx                                   1                    [OK]\n<\/pre><\/div>\n\n\n\n

\u4ec5\u4ec5\u4e3a\u4e86\u6d4b\u8bd5\uff0c\u6211\u4eec\u9009\u62e9\u5b98\u65b9\u955c\u50cf\uff08docker.io\/nginx\uff09\uff0c\u4e0b\u9762\u6211\u4eec\u62c9\u53d6\u955c\u50cf docker pull docker.io\/nginx<\/p>\n\n\n\n

Using default tag: latest\nTrying to pull repository docker.io\/library\/nginx ... \nlatest: Pulling from docker.io\/library\/nginx\nbb79b6b2107f: Pull complete \n111447d5894d: Pull complete \na95689b8e6cb: Pull complete \n1a0022e444c2: Pull complete \n32b7488a3833: Pull complete \nDigest: sha256:ed7f815851b5299f616220a63edac69a4cc200e7f536a56e421988da82e44ed8\nStatus: Downloaded newer image for docker.io\/nginx:latest<\/pre><\/div>\n\n\n\n

\u67e5\u770b\u672c\u5730\u955c\u50cf docker images -a<\/p>\n\n\n\n

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\ndocker.io\/nginx     latest              f35646e83998        2 weeks ago         133 MB\n<\/pre><\/div>\n\n\n\n

\u542f\u7528docker \u4e0b\u9762\u7684nginx\uff0c\u4e3a\u4e86\u65b9\u4fbf\u770b\u6548\u679c\uff0c\u6211\u4eec\u9700\u8981\u505c\u6b62\u4e00\u4e0b\u5916\u9762\u7684nginx(\/web\/nginx\/sbin\/nginx -s stop)\u3002<\/p>\n\n\n\n

docker run –name nginx-test -p 80:80 -d nginx<\/p>\n\n\n\n

1ac537ed852f725cfe36976f1476267a41885b345e8d5d31411f7abaf30bcc64<\/p>\n\n\n\n

\u542f\u52a8\u6210\u529f\u540e\uff0c\u7cfb\u7edf\u4f1a\u7ed9\u51fa\u5bb9\u5668ID\u3002<\/p>\n\n\n\n

-d \u542f\u7528\u540e\u53f0\u8fdb\u7a0b\u3002 -p \u505a\u4e86\u7aef\u53e3\u6620\u5c04\u3002 -name \u4f5c\u4e3a\u5bb9\u5668\u522b\u540d\u3002<\/p>\n\n\n\n

\u67e5\u770b\u8fdb\u7a0b\uff1adocker ps -a<\/p>\n\n\n\n

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES\n1ac537ed852f        nginx               \"\/docker-entrypoin...\"   2 minutes ago       Up 2 minutes        0.0.0.0:80->80\/tcp   nginx-test<\/pre><\/div>\n\n\n\n

\u6211\u4eec\u53ef\u4ee5\u770b\u5230 container ID \u4e3a\u540e\u7aef\u7684\u5bb9\u5668ID\u524d\u4e00\u6bb5\u3002 NAMES\u4e3a\u6211\u4eec\u8d77\u7684\u5bb9\u5668\u522b\u540d\uff0cPORTS\u7ed9\u51fa\u4e86\u7aef\u53e3\u6620\u5c04\u3002<\/p>\n\n\n\n

\u505c\u6b62\u8fdb\u7a0b: docker stop nginx-test<\/p>\n\n\n\n

\u505c\u6b62\u540e\uff0c\u6211\u4eec\u7528docker ps -a \u67e5\u770b<\/p>\n\n\n\n

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES\n1ac537ed852f        nginx               \"\/docker-entrypoin...\"   4 minutes ago       Exited (0) 14 seconds ago                       nginx-test\n<\/pre><\/div>\n\n\n\n

status\u72b6\u6001\u53d1\u751f\u4e86\u6539\u53d8\uff0c\u7531\u539f\u6765\u7684UP\u72b6\u6001\u6539\u6210\u4e86 Exited(0)\u3002<\/p>\n\n\n\n

\u6211\u4eec\u91cd\u65b0\u8fd0\u884c docker run –name nginx-test -p 80:80 -d nginx<\/p>\n\n\n\n

\/usr\/bin\/docker-current: Error response from daemon: Conflict. The container name \"\/nginx-test\" is already in use by container 1ac537ed852f725cfe36976f1476267a41885b345e8d5d31411f7abaf30bcc64. You have to remove (or rename) that container to be able to reuse that name..\nSee '\/usr\/bin\/docker-current run --help'.<\/pre><\/div>\n\n\n\n

\u7cfb\u7edf\u544a\u8bc9\u6211\u4eec\uff0c\u9700\u8981\u5220\u9664\uff0c\u6216\u8005\u6539\u540d nignx-test\u3002 docker rm nginx-test<\/p>\n\n\n\n

\u6211\u4eec\u53ef\u4ee5\u7528 docker start [\u5bb9\u5668ID<\/span>|<\/span>\u5bb9\u5668\u522b\u540d<\/span>] \u542f\u52a8\u3002<\/p>\n\n\n\n

\u6211\u4eec\u91cd\u65b0\u8dd1\u4e00\u4e0bnginx\uff0c\u6211\u4eec\u9700\u8981\u770b\u4e0b\u5916\u9762\u7684\u4e16\u754c\u3002<\/p>\n\n\n\n

\"%title\u63d2\u56fe%num\"<\/figure>\n\n\n\n

\u597d\u4e86\uff0cdocker\u7684\u57fa\u672c\u4f53\u9a8c\u5b8c\u6bd5\uff0c\u6211\u4eec\u8981\u6e05\u7406\u4e00\u4e0b\u54af\u3002<\/p>\n\n\n\n

docker stop nginx-test \/\/\u505c\u6b62\u6211\u4eec\u7684nginx-test \u5bb9\u5668<\/p>\n\n\n\n

docker rm nginx-test \/\/\u5220\u9664\u6211\u4eec\u7684nginx-test \u5bb9\u5668<\/p>\n\n\n\n

docker rmi nginx -f \/\/\u5220\u9664\u6211\u4eec\u4e4b\u524d\u4e0b\u8f7d\u7684nginx \u955c\u50cf<\/p>\n","protected":false},"excerpt":{"rendered":"

CENTOS7\u4e0b\u5f00\u542fDocker,CenterOS7\u5b89\u88c5docker\u8981\u6c42\u5185\u6838\u7248\u672c\u57283.10\u4ee5\u4e0a(uname -… <\/p>\n