zoukankan      html  css  js  c++  java
  • 【docker学习二】CentOS7.5+Docker 镜像(容器)的使用

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

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

    先在官网找到一个镜像:

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

    查看本地镜像

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

    查看本地容器有哪些

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

    根据镜像创建容器

    docker container run  
    --name=mysqlofmine(container的名字)
    --publish=3306:3306  
    --volume=/data/mysql/:/var/lib/mysql/  
    --restart=always  
    --env=MYSQL_ROOT_PASSWORD=123456 
    -d centos/mysql-57-centos7(image的名字)
  • 相关阅读:
    炒炒饼分锅喂
    奥运会
    360和腾讯QQ共存
    Lenovo F41 使用WinXP不能全屏看Flash格式的电影的解决方法
    如何在Windows server 2003上安装和设置Citrix MetaFrame XP FR3
    “电脑人才”是怎么炼成的
    Lenovo F41 使用WinXP不能全屏看Flash格式的电影的解决方法
    学车
    终于有了自己的本本了
    学车
  • 原文地址:https://www.cnblogs.com/the-fool/p/11054098.html
Copyright © 2011-2022 走看看