专业广州网站建设,好设计官网,wordpress user_activation_key,网站域名怎么做解析前些天发现了一个巨牛的人工智能学习网站#xff0c;通俗易懂#xff0c;风趣幽默#xff0c;忍不住分享一下给大家。点击跳转到教程。
1. 查看docker信息#xff08;version、info#xff09;
# 查看docker版本
$docker version # 显示docker系统的信息
$docker i…前些天发现了一个巨牛的人工智能学习网站通俗易懂风趣幽默忍不住分享一下给大家。点击跳转到教程。
1. 查看docker信息version、info
# 查看docker版本
$docker version # 显示docker系统的信息
$docker info
2. 对image的操作search、pull、images、rmi、history
[plain] view plain copy
# 检索image
$docker search image_name # 下载image
$docker pull image_name # 列出镜像列表; -a, --allfalse Show all images; --no-truncfalse Dont truncate output; -q, --quietfalse Only show numeric IDs
$docker images # 删除一个或者多个镜像; -f, --forcefalse Force; --no-prunefalse Do not delete untagged parents
$docker rmi image_name # 显示一个镜像的历史; --no-truncfalse Dont truncate output; -q, --quietfalse Only show numeric IDs
$docker history image_name 3. 启动容器run
docker容器可以理解为在沙盒中运行的进程。这个沙盒包含了该进程运行所必须的资源包括文件系统、系统类库、shell 环境等等。但这个沙盒默认是不会运行任何程序的。你需要在沙盒中运行一个进程来启动某一个容器。这个进程是该容器的唯一进程所以当该进程结束的时候容器也会完全的停止。 # 在容器中运行echo命令输出hello word
$docker run image_name echo hello word # 交互式进入容器中
$docker run -i -t image_name /bin/bash # 在容器中安装新的程序
$docker run image_name apt-get install -y app_name Note 在执行apt-get 命令的时候要带上-y参数。如果不指定-y参数的话apt-get命令会进入交互模式需要用户输入命令来进行确认但在docker环境中是无法响应这种交互的。apt-get 命令执行完毕之后容器就会停止但对容器的改动不会丢失。
4. 查看容器ps
# 列出当前所有正在运行的container
$docker ps
# 列出所有的container
$docker ps -a
# 列出最近一次启动的container
$docker ps -l
5. 保存对容器的修改commit
当你对某一个容器做了修改之后通过在容器中运行某一个命令可以把对容器的修改保存下来这样下次可以从保存后的最新状态运行该容器。
# 保存对容器的修改; -a, --author Author; -m, --message Commit message
$docker commit ID new_image_name
Note image相当于类container相当于实例不过可以动态给实例安装新软件然后把这个container用commit命令固化成一个image。 6. 对容器的操作rm、stop、start、kill、logs、diff、top、cp、restart、attach # 删除所有容器
$docker rm docker ps -a -q # 删除单个容器; -f, --forcefalse; -l, --linkfalse Remove the specified link and not the underlying container; -v, --volumesfalse Remove the volumes associated to the container
$docker rm Name/ID # 停止、启动、杀死一个容器
$docker stop Name/ID
$docker start Name/ID
$docker kill Name/ID # 从一个容器中取日志; -f, --followfalse Follow log output; -t, --timestampsfalse Show timestamps
$docker logs Name/ID # 列出一个容器里面被改变的文件或者目录list列表会显示出三种事件A 增加的D 删除的C 被改变的
$docker diff Name/ID # 显示一个运行的容器里面的进程信息
$docker top Name/ID # 从容器里面拷贝文件/目录到本地一个路径
$docker cp Name:/container_path to_path
$docker cp ID:/container_path to_path # 重启一个正在运行的容器; -t, --time10 Number of seconds to try to stop for before killing the container, Default10
$docker restart Name/ID # 附加到一个运行的容器上面; --no-stdinfalse Do not attach stdin; --sig-proxytrue Proxify all received signal to the process
$docker attach ID Note attach命令允许你查看或者影响一个运行的容器。你可以在同一时间attach同一个容器。你也可以从一个容器中脱离出来是从CTRL-C。 7. 保存和加载镜像save、load
当需要把一台机器上的镜像迁移到另一台机器的时候需要保存镜像与加载镜像。
plain] view plain copy
# 保存镜像到一个tar包; -o, --output Write to an file
$docker save image_name -o file_path
# 加载一个tar包格式的镜像; -i, --input Read from a tar archive file
$docker load -i file_path # 机器a
$docker save image_name /home/save.tar
# 使用scp将save.tar拷到机器b上然后
$docker load /home/save.tar
8、 登录registry serverlogin
# 登陆registry server; -e, --email Email; -p, --password Password; -u, --username Username
$docker login
9. 发布imagepush
# 发布docker镜像
$docker push new_image_name 10. 根据Dockerfile 构建出一个容器 #build --no-cachefalse Do not use cache when building the image -q, --quietfalse Suppress the verbose output generated by the containers --rmtrue Remove intermediate containers after a successful build -t, --tag Repository name (and optionally a tag) to be applied to the resulting image in case of success
$docker build -t image_name Dockerfile_path 另外也推荐 Docker 常用命令 和 Docker 命令整理 原文见https://blog.csdn.net/we_shell/article/details/38368137