iis服务器助手广告广告
返回顶部
首页 > 资讯 > 服务器 >Docker容器的使用方法简单示例
  • 868
分享到

Docker容器的使用方法简单示例

2024-04-02 19:04:59 868人浏览 独家记忆
摘要

目录一、拉取镜像二、运行镜像三、测试容器内的应用四、检查宿主机端口五、停止容器一、拉取镜像 1.检测镜像是否存在 [root@node1 ~]# Docker search Ng

一、拉取镜像

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容器使用内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Docker容器的使用方法简单示例

本文链接: https://www.lsjlt.com/news/131052.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Docker容器的使用方法简单示例
    目录一、拉取镜像二、运行镜像三、测试容器内的应用四、检查宿主机端口五、停止容器一、拉取镜像 1.检测镜像是否存在 [root@node1 ~]# docker search ng...
    99+
    2024-04-02
  • docker容器的简单使用
    这篇文章主要讲解了“docker容器的简单使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“docker容器的简单使用”吧!1 查看ID查看docker容器...
    99+
    2024-04-02
  • docker-compose简单使用方法详解
    目录Compose介绍一、前置条件二、使用方法三、测试Compose介绍 Docker Compose是一个用来定义和运行复杂应用的Docker工具。一个使用Docker容器的应用,...
    99+
    2022-11-13
    docker compose使用 docker compose
  • es6中some和every方法使用简单示例
    目录1、some方法举例如下图所示:2、every方法举例:3、回调函数没有(主动)返回4、特殊情况总结一下,有三个重要的点:文章略长,但比较简单。 es6中的数组方法some()和...
    99+
    2023-05-14
    es6 every some es6的some方法 es6 every方法
  • 在koa中简单使用Websocket连接的方法示例
    目录前言ws模块安装websocket初始化websocket下发数据总结前言 在一次项目需求会上,有个新需求是要让用户从管理后台主动下发数据到app前端,从而让前端那边对这主动下发...
    99+
    2024-04-02
  • MySQL触发器简单用法示例
    本文实例讲述了MySQL触发器简单用法。分享给大家供大家参考,具体如下: mysql触发器和存储过程一样,是嵌入到mysql的一段程序,触发器是由事件来触发的,这些事件包括,INSERT,UPDATE,DE...
    99+
    2024-04-02
  • Docker简单部署ElasticSearch的方法
    这篇“Docker简单部署ElasticSearch的方法”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一...
    99+
    2024-04-02
  • Docker容器使用方法详解
    目录一、新建并启动二、启动已终止容器三、后台运行四、终止容器五、进入容器六、删除容器一、新建并启动 所需要的命令主要为 dockerrun。例如,下⾯的命令输出⼀个“He...
    99+
    2024-04-02
  • js中indexOf()的简单使用示例
    目录语法:定义用法及实例补充知识:不区分大小写的 javascript indexOf总结语法: String.IndexOf(Char, [startIndex], [count]...
    99+
    2023-01-12
    js indexof的用法 js数组indexof用法 indexof的用法
  • SpringDataRedis简单使用示例代码
    目录spring-data-redisspring-data-redis的特性SpringBoot的版本是2.xSpringDataRedis自动序列化Spring默认提供的Stri...
    99+
    2023-02-03
    SpringDataRedis使用 SpringData Redis
  • Java二维数组简单定义与使用方法示例
    本文实例讲述了Java二维数组简单定义与使用方法。分享给大家供大家参考,具体如下:Java的二维数组是先创建一个一维数组,然后该数组的元素再引用另外一个一维数组。在使用二维数组的时候,通过两个中括号[]来访问每一层维度的引用,直到访问到最终...
    99+
    2023-05-31
    java 二维数组 ava
  • Docker容器使用方法是什么
    这篇文章主要介绍了Docker容器使用方法是什么的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Docker容器使用方法是什么文章都会有所收获,下面我们一起来看看吧。新建并启动所需要的命令主要为 dockerru...
    99+
    2023-07-02
  • docker容器使用GPU方法实现
    目录1、无nvidia-docker2、nvidia-docker1.03、nvidia-docker2.04、安装docker-19.03及以上版本为了使docker容器可以使用n...
    99+
    2024-04-02
  • python-docx的简单使用示例教程
    python-docx的简单使用 ''' 设置表格所有单元格的四个边为0.5磅,黑色,实线 可以使用返回值,也可以不使用 ''' def 设置表格网格线为黑色实线(table_obj...
    99+
    2023-05-18
    python-docx使用 python-docx
  • Vuejs的简单使用方法
    这篇文章主要介绍“Vuejs的简单使用方法”,在日常操作中,相信很多人在Vuejs的简单使用方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Vuejs的简单使用方法”的疑惑...
    99+
    2024-04-02
  • Vue3使用路由VueRouter4的简单示例
    路由 vue-router4保持了大部分API不变,我们只关注变化部分即可。 安装 yarn add vue-router@4 引入 cdn <script s...
    99+
    2024-04-02
  • java 中反射简单使用示例
    这篇文章将为大家详细讲解有关java 中反射简单使用示例,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。package reflect_test;public class Do...
    99+
    2023-06-02
  • python中注释用法简单示例
    目录python中注释注释描述注释截图:1.单行注释 :2.多行注释:3.文档注释补充:注释程序总结 python中注释 在python中的注释一般分为单行注释、多行注释以...
    99+
    2023-02-04
    python 注释 python注释语法
  • Android传感器的简单使用方法
    本文实例为大家分享了Android传感器简单使用的具体代码,供大家参考,具体内容如下 1. SensorManager类 SensorManager类用来管理各个传感器:通过Sens...
    99+
    2024-04-02
  • Java NIO框架Netty简单使用的示例
    之前写了一篇文章:Java 网络IO编程总结(BIO、NIO、AIO均含完整实例代码),介绍了如何使用Java原生IO支持进行网络编程,本文介绍一种更为简单的方式,即Java NIO框架。Netty是业界最流行的NIO框架之一,具有良好的健...
    99+
    2023-05-30
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作