Docker学习笔记3

作者: miko_haha | 来源:发表于2017-06-08 21:50 被阅读89次

相关命令

  • 通用
操作 命令 示例
查看版本 docker version docker version
查看信息 docker info docker info
查看某命令 help 信息 docker help [command] docker help attach
查看 docker help 信息 docker --help docker --help
  • image相关
操作 命令 示例
通过容器创建镜像 docker commit [container][imageName] docker commit nostalgic_morse ouruser/sinatra:v2
通过dockerfile创建镜像 docker build -t [imageName] [pathFile] docker build -t jdk .
查看本地所有镜像 docker images docker images
从 registry 中获取镜像(若无指定 tag 名称,则默认使用 latest 这个 tag) docker pull [imageName] docker pull jdk
给镜像打tag docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] $ docker tag httpd:test fedora/httpd:version1.0.test
镜像上传到registry docker push [image] docker push jdk
删除本地镜像 docker rmi [image] docker rmi jdk
  • container相关
操作 命令 示例
创建 docker create docker create testmk12/jdk
创建并运行 docker run docker run testmk12/jdk
创建并运行container后进入其bash控制台 docker run -t -i image /bin/bash docker run -t -i ubuntu /bin/bash
创建并运行container并让其在后台运行,并端口映射 docker run -p [port in container]:[port in physical system] -d [image] [command] docker run -p 3306:3306 -d testmk12/jdk
查看正在运行的所有container信息 docker ps docker ps
查看最后创建的container docker ps -l docker ps -l
停止container docker stop [container] docker stop tomcat
强制停止container docker kill [container] docker kill tomcat
启动container docker start [container] docker start jdk
重启container docker restart [container] docker restart tomcat
删除container docker rm [container] docker rm tomcat

相关文章

网友评论

    本文标题:Docker学习笔记3

    本文链接:https://www.haomeiwen.com/subject/xjotqxtx.html