Docker容器的使用方法簡單示例,Docker容器方法示例

目錄

  • 一、拉取鏡像
  • 二、運行鏡像
  • 三、測試容器內的應用
  • 四、檢查宿主機端口
  • 五、停止容器
 
一、拉取鏡像1.檢測鏡像是否存在
【Docker容器的使用方法簡單示例,Docker容器方法示例】[root@node1 ~]# docker search nginxNAMEDESCRIPTIONSTARSOFFICIALAUTOMATEDnginxOfficial build of Nginx.15187[OK]jwilder/nginx-proxyAutomated Nginx reverse proxy for docker con…2048[OK]richarvey/nginx-php-fpmContainer running Nginx + PHP-FPM capable of…816[OK]jc21/nginx-proxy-managerDocker container for managing Nginx proxy ho…218linuxserver/nginxAn Nginx container, brought to you by LinuxS…149tiangolo/nginx-rtmpDocker image with Nginx using the nginx-rtmp…136[OK]jlesage/nginx-proxy-managerDocker container for Nginx Proxy Manager123[OK]alfg/nginx-rtmpNGINX, nginx-rtmp-module and FFmpeg from sou…102[OK]jasonrivers/nginx-rtmpDocker images to host RTMP streams using NGI…92[OK]nginxdemos/helloNGINX webserver that serves a simple page co…70[OK]privatebin/nginx-fpm-alpinePrivateBin running on an Nginx, php-fpm & Al…56[OK]nginx/nginx-ingressNGINX andNGINX Plus Ingress Controllers fo…55nginxinc/nginx-unprivilegedUnprivileged NGINX Dockerfiles45staticfloat/nginx-certbotOpinionated setup for automatic TLS certs lo…24[OK]nginx/nginx-prometheus-exporterNGINX Prometheus Exporter for NGINX and NGIN…19schmunk42/nginx-redirectA very simple container to redirect HTTP tra…19[OK]centos/nginx-112-centos7Platform for running nginx 1.12 or building …15centos/nginx-18-centos7Platform for running nginx 1.8 or building n…13raulr/nginx-wordpressNginx front-end for the official wordpress:f…13[OK]bitwarden/nginxThe Bitwarden nginx web server acting as a r…11flashspys/nginx-staticSuper Lightweight Nginx Image10[OK]mailu/nginxMailu nginx frontend9[OK]sophos/nginx-vts-exporterSimple server that scrapes Nginx vts stats a…7[OK]ansibleplaybookbundle/nginx-apbAn APB to deploy NGINX2[OK]wodby/nginxGeneric nginx12.拉取下載鏡像
[root@node1 ~]# docker pull nginxUsing default tag: latestlatest: Pulling from library/nginxb4d181a07f80: Pull complete 66b1c490df3f: Pull complete d0f91ae9b44c: Pull complete baf987068537: Pull complete 6bbc76cbebeb: Pull complete 32b766478bc2: Pull complete Digest: sha256:353c20f74d9b6aee359f30e8e4f69c3d7eaea2f610681c4a95849a2fd7c497f9Status: Downloaded newer image for nginx:latestdocker.io/library/nginx:latest3.查看本地鏡像
[root@node1 ~]# docker image lsREPOSITORYTAGIMAGE IDCREATEDSIZEnginxlatest4cdc5dd7eaad2 weeks ago133MB 
二、運行鏡像1.安裝相關包
[root@node1 ~]# yum install -y libseccomp-devel Updating Subscription Management repositories.Unable to read consumer identityThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Repository AppStream is listed more than once in the configurationRepository AppStream is listed more than once in the configurationRepository BaseOS is listed more than once in the configurationRepository AppStream is listed more than once in the configurationRepository BaseOS is listed more than once in the configurationDocker CE Nightly - Sources798B/s | 2.3 kB00:02ansiable0.0B/s |0B00:00Failed to synchronize cache for repo 'docker-ce-nightly-source', ignoring this repo.Failed to synchronize cache for repo 'ansiable', ignoring this repo.Last metadata expiration check: 2:32:21 ago on Wed 21 Jul 2021 07:51:23 PM CST.Dependencies resolved.=============================================================================================================================================== PackageArchVersionRepositorySize===============================================================================================================================================Installing: libseccomp-develx86_642.5.1-1.el8AppStream57 kUpgrading: libseccompx86_642.5.1-1.el8base71 kTransaction Summary===============================================================================================================================================Install1 PackageUpgrade1 PackageTotal download size: 128 kDownloading Packages:(1/2): libseccomp-2.5.1-1.el8.x86_64.rpm256 kB/s |71 kB00:00(2/2): libseccomp-devel-2.5.1-1.el8.x86_64.rpm186 kB/s |57 kB00:00-----------------------------------------------------------------------------------------------------------------------------------------------Total414 kB/s | 128 kB00:00Running transaction checkTransaction check succeeded.Running transaction testTransaction test succeeded.Running transactionPreparing:1/1Upgrading: libseccomp-2.5.1-1.el8.x86_641/3Running scriptlet: libseccomp-2.5.1-1.el8.x86_641/3Installing: libseccomp-devel-2.5.1-1.el8.x86_642/3Cleanup: libseccomp-2.3.3-3.el8.x86_643/3Running scriptlet: libseccomp-2.3.3-3.el8.x86_643/3Verifying: libseccomp-devel-2.5.1-1.el8.x86_641/3Verifying: libseccomp-2.5.1-1.el8.x86_642/3Verifying: libseccomp-2.3.3-3.el8.x86_643/3 Installed products updated.Upgraded:libseccomp-2.5.1-1.el8.x86_64Installed:libseccomp-devel-2.5.1-1.el8.x86_64Complete!

推薦閱讀