承接上篇:https://mp.csdn.net/postedit/82744127

上文介绍了容器与镜像的基本操作,这里总结下容器的使用。

先在官网找到一个镜像:

  1. https://hub.docker.com/r/centos/mysql-57-centos7/
  1. [root@localhost mydc]# docker search centos
  2. FROM ubuntu
  3. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  4. centos The official build of CentOS. 4722 [OK]
  5. ansible/centos7-ansible Ansible on Centos7 118 [OK]
  6. jdeathe/centos-ssh CentOS-6 6.10 x86_64 / CentOS-7 7.5.1804 x86 99 [OK]
  7. consol/centos-xfce-vnc Centos container with "headless" VNC session 63 [OK]
  8. imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 45 [OK]
  9. tutum/centos Simple CentOS docker image with SSH access 43
  10. centos/mysql-57-centos7 MySQL 5.7 SQL database server 39
  11. gluster/gluster-centos Official GlusterFS Image [ CentOS-7 + Glust 34 [OK]
  12. openshift/base-centos7 A Centos7 derived base image for Source-To-I 33
  13. centos/python-35-centos7 Platform for building and running Python 3.5 30
  14. centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relational 29
  15. kinogmt/centos-ssh CentOS with SSH 22 [OK]
  16. openshift/jenkins-2-centos7 A Centos7 based Jenkins v2.x image for use w 15
  17. pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag names 7
  18. openshift/wildfly-101-centos7 A Centos7 based WildFly v10.1 image for use 5
  19. openshift/jenkins-1-centos7 DEPRECATED: A Centos7 based Jenkins v1.x ima 4
  20. darksheer/centos Base Centos Image -- Updated hourly 3 [OK]
  21. pivotaldata/centos Base centos, freshened up a little with a Do 2
  22. pivotaldata/centos-mingw Using the mingw toolchain to cross-compile t 2
  23. blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK]
  24. pivotaldata/centos-gcc-toolchain CentOS with a toolchain, but unaffiliated wi 0
  25. pivotaldata/centos7-build CentosOS 7 image for GPDB compilation 0
  26. smartentry/centos centos with smartentry 0 [OK]
  27. jameseckersall/sonarr-centos Sonarr on CentOS 7 0 [OK]
  28. pivotaldata/centos7-test CentosOS 7 image for GPDB testing 0
  29. [root@localhost mydc]# docker pull centos/mysql-57-centos7
  30. Using default tag: latest
  31. latest: Pulling from centos/mysql-57-centos7
  32. 256b176beaff: Pull complete
  33. efb19fea0fdb: Pull complete
  34. b4570fdc208c: Pull complete
  35. 213e4e250552: Pull complete
  36. 455c976d8b6f: Pull complete
  37. 2d8a583c0d63: Pull complete
  38. 997ede30fc40: Pull complete
  39. 5cc4480f88a0: Pull complete
  40. 2e721eb8f5f6: Pull complete
  41. Digest: sha256:c8a8323721c60a49b1792d31a7892731c741d58c238d77b42f0dcf8d7c32c1b4
  42. Status: Downloaded newer image for centos/mysql-57-centos7:latest
  43. [root@localhost mydc]# docker images
  44. REPOSITORY TAG IMAGE ID CREATED SIZE
  45. centos/mysql-57-centos7 latest 34300611d53e 9 days ago 445MB
  46. ubuntu latest cd6d8154f1e1 13 days ago 84.1MB
  47. [root@localhost mydocker]# docker run -d --name mysql_database -e MYSQL_USER=root -e MYSQL_PASSWORD= -e MYSQL_DATABASE=db -p 3306:3306 centos/mysql-57-centos7
  48. f443dd67716c2ffd0570caa35a3aa499c1d1fb65fcc6c6859fa315a51d48777b

查看本地镜像

  1. [root@localhost admin]# docker image list
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. ubuntu_mine latest d0ec321b73c6 7 days ago 84.1MB
  4. centos/mysql-57-centos7 latest 34300611d53e 2 weeks ago 445MB
  5. ubuntu latest cd6d8154f1e1 2 weeks ago 84.1MB
  6. mysql/mysql-server latest 1fdf3806e715 6 weeks ago 309MB

查看本地容器有哪些

  1. [root@localhost admin]# docker container list
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. 27c2fb71f4e9 centos/mysql-57-centos7 "container-entrypoin…" 4 minutes ago Restarting (1) 23 seconds ago mysqlofmine
  4. [root@localhost admin]#

根据镜像创建容器

  1. docker container run
  2. --name=mysqlofminecontainer的名字)
  3. --publish=3306:3306
  4. --volume=/data/mysql/:/var/lib/mysql/
  5. --restart=always
  6. --env=MYSQL_ROOT_PASSWORD=123456
  7. -d centos/mysql-57-centos7(image的名字)

【docker学习二】CentOS7.5+Docker 镜像(容器)的使用的更多相关文章

  1. <Docker学习>2.Centos7安装docker

    Docker CE 支持 64 位版本 CentOS 7,并且要求内核版本不低于 3.10. CentOS 7 满足最低内核的要求,但由于内核版本比较低,部分功能(如 overlay2 存储层驱动)无 ...

  2. Docker学习笔记之--.Net Core应用容器通过网桥连接Redis容器(环境:centos7)

    上节演示通过应用容器连接sql server容器,连接:Docker学习笔记之--.Net Core项目容器连接mssql容器(环境:centos7) 本节演示安装 redis容器,通过网桥连接 先决 ...

  3. Docker学习之Centos7下安装

    Docker学习之Centos7下安装 centos7 64下直接使用yum安装docker环境,步骤如下: 卸载旧版本docker sudo yum remove docker docker-com ...

  4. Docker学习(十)Docker容器编排 Docker-compose

    Docker学习(十)Docker容器编排 Docker-compose 标签(空格分隔): docker 容器编排是什么 应用一般由单独容器化的组件组成,须按照一定顺序在网络级别进行组织,以使其能够 ...

  5. [转]Docker学习之四:使用docker安装mysql

    本文转自:https://blog.csdn.net/qq_19348391/article/details/82998391 Docker学习之一:注册Docker Hub账号 Docker学习之二 ...

  6. Docker学习(十一)Docker系列结束-新的开始K8S

    Docker学习(十一)Docker系列结束-新的开始K8S 标签(空格分隔): docke k8s Docker系列结束 上一篇讲到使用docker官方提供的容器编排工具docker-compose ...

  7. Docker学习笔记之--.Net Core项目容器连接mssql容器(环境:centos7)

    前一节演示在docker中安装mssql,地址:Docker学习笔记之--安装mssql(Sql Server)并使用Navicat连接测试(环境:centos7) 本节演示 .Net Core项目容 ...

  8. Docker学习笔记-CentOS7镜像

    前言: 环境:centos7.5 64 位 正文: 第一步:下载centos7镜像 docker pull centos 第二步:建立centos7的容器 sudo docker run --priv ...

  9. docker 学习之路 将docker容器变为镜像并上传

    环境 ubunt 16.4 去hub.docker.com上注册一个账号,并在账号中注册一个公有public或者私有仓库private 步骤如下 如上图 点击该处进入创建docker库页面 除了名字之 ...

  10. docker学习-lnmp+redis之搭建lnp容器服务

    nginx+php7.0容器服务 本来想用单独的容器(nginx和php分开),但是因为是初学,php容器安装扩展的时候一直失败,所以就把centos+nginx+php放一起搭建了,优点是扩展简单, ...

随机推荐

  1. [LeetCode] Subsets [31]

    题目 Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must ...

  2. Leetcode 94 Binary Tree Inorder Traversal 二叉树

    二叉树的中序遍历,即左子树,根, 右子树 /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *lef ...

  3. 机器学习: TensorFlow with MLP 笑脸识别

    Tensor Flow 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edges)则表示在节点间相互联系的多维数据数 ...

  4. uwp 沉浸式状态栏

    //隐藏状态栏if (ApiInformation.IsTypePresent(typeof(StatusBar).ToString())) { StatusBar statusBar = Statu ...

  5. BZOJ 3594 Scoi2014 方波波麦田 树阵

    标题效果:给定一个序列,能够选择k次每个部分的数量和在范围内+1,寻求操作后LIS最大值 我的做法是不是一个标准的解决方案. ..5E为什么跑飞的复杂性. . . 首先,显而易见的结论是,我们选择k右 ...

  6. ABP缓存示例

    private readonly ICacheManager _cacheManager; public ProgrammeManage(ICacheManager cacheManager) { _ ...

  7. WPF中获取TreeView以及ListView获取其本身滚动条的方法,可实现自行调节scoll滚动的位置(可相应获取任何控件中的内部滚动条)

    原文:WPF中获取TreeView以及ListView获取其本身滚动条的方法,可实现自行调节scoll滚动的位置(可相应获取任何控件中的内部滚动条) 对于TreeView而言: TreeViewAut ...

  8. 支持chrome30下载文件

    function downloadX(url ,fileName){ const xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr ...

  9. Win10《芒果TV》更新v3.8.30流星版:优化稳定性、升级无边框播放体验

    随着暑假到来,大波王牌综艺和青春电视剧热浪来袭,Win10版<芒果TV>全平台同步更新流星版v3.8.30,进一步提升稳定性,巩固播放体验,升级剧场模式和画中画无边框体验,我们在芒果等你. ...

  10. JavaScript关于原型的相关内容

    function Person () { } Person.prototype.name = 'Alan'; Person.prototype.age = 26; Person.prototype.j ...