docker容器的标准使用过程(Docker容器的使用方法简单示例)
类别:服务器 浏览量:244
时间:2021-10-11 00:45:23 docker容器的标准使用过程
Docker容器的使用方法简单示例目录
- 一、拉取镜像
- 二、运行镜像
- 三、测试容器内的应用
- 四、检查宿主机端口
- 五、停止容器
1.检测镜像是否存在
[root@node1 ~]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 15187 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 2048 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 816 [OK] jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 218 linuxserver/nginx An Nginx container, brought to you by LinuxS… 149 tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 136 [OK] jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 123 [OK] alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from sou… 102 [OK] jasonrivers/nginx-rtmp Docker images to host RTMP streams using NGI… 92 [OK] nginxdemos/hello NGINX webserver that serves a simple page co… 70 [OK] privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, php-fpm & Al… 56 [OK] nginx/nginx-ingress NGINX and NGINX Plus Ingress Controllers fo… 55 nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 45 staticfloat/nginx-certbot Opinionated setup for automatic TLS certs lo… 24 [OK] nginx/nginx-prometheus-exporter NGINX Prometheus Exporter for NGINX and NGIN… 19 schmunk42/nginx-redirect A very simple container to redirect HTTP tra… 19 [OK] centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 15 centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 13 raulr/nginx-wordpress Nginx front-end for the official wordpress:f… 13 [OK] bitwarden/nginx The Bitwarden nginx web server acting as a r… 11 flashspys/nginx-static Super Lightweight Nginx Image 10 [OK] mailu/nginx Mailu nginx frontend 9 [OK] sophos/nginx-vts-exporter Simple server that scrapes Nginx vts stats a… 7 [OK] ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 2 [OK] wodby/nginx Generic nginx 1
2.拉取下载镜像
[root@node1 ~]# docker pull nginx Using default tag: latest latest: Pulling from library/nginx b4d181a07f80: Pull complete 66b1c490df3f: Pull complete d0f91ae9b44c: Pull complete baf987068537: Pull complete 6bbc76cbebeb: Pull complete 32b766478bc2: Pull complete Digest: sha256:353c20f74d9b6aee359f30e8e4f69c3d7eaea2f610681c4a95849a2fd7c497f9 Status: Downloaded newer image for nginx:latest docker.io/library/nginx:latest
3.查看本地镜像
[root@node1 ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 4cdc5dd7eaad 2 weeks ago 133MB
1.安装相关包
[root@node1 ~]# yum install -y libseccomp-devel Updating Subscription Management repositories. Unable to read consumer identity This 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 configuration Repository AppStream is listed more than once in the configuration Repository BaseOS is listed more than once in the configuration Repository AppStream is listed more than once in the configuration Repository BaseOS is listed more than once in the configuration Docker CE Nightly - Sources 798 B/s | 2.3 kB 00:02 ansiable 0.0 B/s | 0 B 00:00 Failed 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. =============================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================== Installing: libseccomp-devel x86_64 2.5.1-1.el8 AppStream 57 k Upgrading: libseccomp x86_64 2.5.1-1.el8 base 71 k Transaction Summary =============================================================================================================================================== Install 1 Package Upgrade 1 Package Total download size: 128 k Downloading Packages: (1/2): libseccomp-2.5.1-1.el8.x86_64.rpm 256 kB/s | 71 kB 00:00 (2/2): libseccomp-devel-2.5.1-1.el8.x86_64.rpm 186 kB/s | 57 kB 00:00 ----------------------------------------------------------------------------------------------------------------------------------------------- Total 414 kB/s | 128 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : libseccomp-2.5.1-1.el8.x86_64 1/3 Running scriptlet: libseccomp-2.5.1-1.el8.x86_64 1/3 Installing : libseccomp-devel-2.5.1-1.el8.x86_64 2/3 Cleanup : libseccomp-2.3.3-3.el8.x86_64 3/3 Running scriptlet: libseccomp-2.3.3-3.el8.x86_64 3/3 Verifying : libseccomp-devel-2.5.1-1.el8.x86_64 1/3 Verifying : libseccomp-2.5.1-1.el8.x86_64 2/3 Verifying : libseccomp-2.3.3-3.el8.x86_64 3/3 Installed products updated. Upgraded: libseccomp-2.5.1-1.el8.x86_64 Installed: libseccomp-devel-2.5.1-1.el8.x86_64 Complete!
2.生成容器
备注:- d 后台运行容器 -p 80:80 端口映射 宿主机端口:容器内端口
[root@node1 ~]# docker run -d -p 80:80 nginx 2716e3ec14173a31d8c2168ceceefbbfecec0efe6d611bc710df0bc53748ef0c
3.查看容器运行状态
[root@node1 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2716e3ec1417 nginx "/docker-entrypoint.…" 26 seconds ago Up 24 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp naughty_driscoll
[root@node1 ~]# netstat -tunlp |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3807/docker-proxy tcp6 0 0 :::80 :::* LISTEN 3814/docker-proxy tcp6 0 0 :::8081 :::* LISTEN 1092/httpd
[root@node1 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2716e3ec1417 nginx "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp naughty_driscoll [root@node1 ~]# docker stop 2716e3ec1417 2716e3ec1417 [root@node1 ~]# docker start 2716e3ec1417 2716e3ec1417
到此这篇关于Docker容器的使用方法简单示例的文章就介绍到这了,更多相关Docker容器使用内容请搜索开心学习网以前的文章或继续浏览下面的相关文章希望大家以后多多支持开心学习网!
您可能感兴趣
- dockerregistry原理(解决Docker x509 insecure registry的问题)
- docker重新加载nginx(Docker Nginx Log 三者的处理详解)
- docker进入容器的命令(Docker 最常用的镜像命令和容器命令详解)
- java连接mongodb(Docker连接mongodb实现过程及代码案例)
- docker harbor 配置中央仓库(Docker Gitlab+Jenkins+Harbor构建持久化平台操作)
- docker部署mysql多实例(Docker部署mysql一主一从的操作方法)
- mysql允许远程访问docker(Docker部署mysql远程连接 解决2003的问题)
- 查看docker image版本(解决docker images 镜像消失的问题)
- docker镜像配置教程(给Docker更换国内镜像源操作)
- docker redis安装配置(在docker中部署并启动redis的方法)
- dockerspringboot一键部署(docker-compose镜像发布springboot项目的流程分析)
- docker配置redis集群(基于Docker搭建Redis主从集群的实现)
- rocketmq安装linux(docker安装rocketMQ教程最详细)
- ubuntu下使用vscode(使用Vscode结合docker进行开发的详细过程)
- docker添加mq基础镜像(Docker阿里云RocketMQ 4.5.1部署流程详解)
- docker-compose查看服务状态(Docker+DockerCompose封装web应用的方法步骤)
- 董元奔吟咏历代文人 1012新旧均可 全椒人张璪 1022 -1093(董元奔吟咏历代文人)
- 泪目 这位 刷屏 的英雄,是全椒人的骄傲(泪目这位刷屏)
- 人从众 火炎焱 全椒再现 正月十六走太平 的魅力(人从众火炎焱全椒再现)
- 官宣 全椒籍明星许海峰 奚秀兰 方芳 王璐瑶携手回家 走太平(全椒籍明星许海峰)
- 以前全椒人是怎么过冬的 满满都是回忆(以前全椒人是怎么过冬的)
- NVIDIA显卡份额冲上88 A饭发愁 游戏优化恐没A卡份了(NVIDIA显卡份额冲上88A饭发愁)
热门推荐
- sqlserver字符串格式化(SQL server中字符串逗号分隔函数分享)
- laravel怎么设置返回指定列(在laravel5.2中实现点击用户头像更改头像的方法)
- iis服务器安装错误(IIS7.0配置过程中出现HTTP 错误 403.14的解决方法)
- 创建自己的Visual Studio工程模板
- 类型初始值设定项引发异常 解决方法
- jQuery判断对象是否存在
- linux什么时候使用信号(浅谈Linux信号机制)
- css3中的过渡属性的几种方法(基于CSS3实现的几个小loading效果)
- css3实现120度的箭头(使用css实现任意大小、任意方向和任意角度的箭头示例)
- php框架创建控制器代码(php连接sftp的作用以及实例代码)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9