zoukankan      html  css  js  c++  java
  • docker 入坑3

    查看镜像

    docker images [OPTIONS] [REPOSITORY[:TAG]]
    
    •  -a, --all=false
    • -f, --filter=[]
    • --no-trunc=false
    • -q, --quite=false ,只显示id

    删除镜像

    $ docker rmi [OPTIONS] IMAGE

    删除所有的镜像
    查询出所有镜像的id
    $ docker images -q ubuntu
    $ docker rmi $(docker images -q ubuntu)

     检索镜像

    $ docker search [OPTIONS] TERM
    --automated=false	Only show automated builds
    --no-trunc=false	Don't truncate output
    -s, --stars=0	Only displays with at least x stars
    

     构建镜像

    1. $ docker commit 通过容器构建
      $ docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
      -a, --author=""	通常填写作者以及联系方式
      -m,--message	Commit message
      -p, --pause=true	Pause container during commit
      

      eg:

      $ docker run -it -p 80 --name commit_test ubuntu /bin/bash
      

       安装nginx

      # apt-get update
      # apt-get install nginx
      

       退出

      docker commit -a '取名' -m 'nginx' commit_test 仓库名字/镜像名字
      $ docker commit -a 'Mantishell' -m 'nginx' commit_test mantishell/commit_test
      $ docker images
      $ docker run -d --name nginx_web -p 80 mantishell/commit_test nginx -g "daemon off;"
      $ docker ps
      
    2. $ docker build 通过Dockerfile文件构建
      $ docker build [OPTIONS] PATH | URL | -
        --force-rm=false
        --no-cache=false
        -q,--quiet=false
        --rm=true
        -t,--tag=""
      

      首先我们创建一个存放dockerfile的目录

      $ mkdir -p dockerfile/df_test
      $ cd /dockerfile/df_test
      $ vim Dockfile
      

       Dockerfile文件的内容

      #First Dockerfile
      FROM ubuntu:14.01
      MAINTAINER mantishell	"825013349@qq.com"
      RUN apt-get update
      RUN apt-get install -y nginx
      EXPOSE 80
      

       创建镜像:

      $ docker build -t='mantishell/df_test' .
      

       测试我们创建的镜像

      docker run -d --name nginx_web2 -p 80 mantishell/df_rest nginx -g "daemon off;"
      

       
  • 相关阅读:
    Debian/Ubuntu/Raspbian 时间同步
    linux 安裝mitmproxy
    Raspbian Lite Guide GUI 树莓派安装桌面
    SSH连接 提示 ssh_exchange_identification: Connection closed by remote host
    Navicat15 永久激活版教程
    docker企业级镜像仓库Harbor管理
    centos7.4安装docker
    Linux系统硬件时间12小时制和24小时制表示设置
    windows server 2012 R2系统安装部署SQLserver2016企业版(转)
    细说show slave status参数详解
  • 原文地址:https://www.cnblogs.com/mantishell/p/11294975.html
Copyright © 2011-2022 走看看