栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

docker常用命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

docker常用命令

 docker所有命令集合

  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

 查看某个命令的使用细节

docker xxx --help

 从官方镜像库拉取镜像

docker pull python:3.7

显示本地镜像

docker image list

使用特定镜像启动一个容器,并进入命令行,注意,如果不带/bin/bash会直接启动python,在终端shell下直接输入exit可以退出终端。

docker run -it python:3.7 /bin/bash
docker run -itd  python:3.7 /bin/bash

 查看运行中的容器

docker ps -a

这里注意,当你运行一个容器后退出,这个容器虽然停止了,但是容器的实体还在。

启动一个已经穿见过的容器,XXX是容器的ID。如果需要shell交互,加 -i

docker start xxxx

对应的,停止一个容器,依然需要知道ID。

docker stop xxx

运行一个exit后不停止的容器

docker exec -it 243c32535da7 /bin/bash

当你基于某个镜像的容器进行了自己的环境配置后,想要导出你的容器,使用一下步骤

导出一个容器

 docker export 861 -o p37numpy.tar

导入一个容器

docker import .p37numpy.tar py37:numpy

如果需要将镜像直接进行保存和载入,可以使用load和save

docker save 24f00 -o p37.tar
docker load -i .p37.tar

注意,如果使用了load,那么会替换一样的镜像。

如果是你改了某镜像的容器,并想把这些更改加入到镜像中,使用命令 

 95是ID, py37numpy是name,928是tag

docker commit -m "add numpy" -a "Yan" 95 py37numpy:928

commit以后就会出现一个新的镜像,可以push这个镜像,这里注意,xxy是你自己的仓库名字

docker push xxy/py37numpy

 查看一个镜像的详细信息

docker inspect xxx

查看docker占用内存情况

docker system df

清理空间,慎用!

docker system prune

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/276954.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号