2019独角兽企业重金招聘Python工程师标准>>>
查看docker的子命令,直接敲docker
或完整的docker help
就可以了:
bash-3.2$ docker
Usage: docker [OPTIONS] COMMAND [arg...]
A self-sufficient runtime for linux containers.
Options:-D, --debug=false Enable debug mode-d, --daemon=false Enable daemon mode-H, --host=[] Daemon socket(s) to connect to-h, --help=false Print usage-l, --log-level=info Set the logging level--tls=false Use TLS; implied by --tlsverify--tlscacert=~/.boot2docker/certs/boot2docker-vm/ca.pem Trust certs signed only by this CA--tlscert=~/.boot2docker/certs/boot2docker-vm/cert.pem Path to TLS certificate file--tlskey=~/.boot2docker/certs/boot2docker-vm/key.pem Path to TLS key file--tlsverify=true Use TLS and verify the remote-v, --version=false Print version information and quit
Commands:attach Attach to a running containerbuild Build an image from a Dockerfilecommit Create a new image from a container's changescp Copy files/folders from a container's filesystem to the host pathcreate Create a new containerdiff Inspect changes on a container's filesystemevents Get real time events from the serverexec Run a command in a running containerexport Stream the contents of a container as a tar archivehistory Show the history of an imageimages List imagesimport Create a new filesystem image from the contents of a tarballinfo Display system-wide informationinspect Return low-level information on a container or imagekill Kill a running containerload Load an image from a tar archivelogin Register or log in to a Docker registry serverlogout Log out from a Docker registry serverlogs Fetch the logs of a containerport Lookup the public-facing port that is NAT-ed to PRIVATE_PORTpause Pause all processes within a containerps List containerspull Pull an image or a repository from a Docker registry serverpush Push an image or a repository to a Docker registry serverrename Rename an existing containerrestart Restart a running containerrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save an image to a tar archivesearch Search for an image on the Docker Hubstart Start a stopped containerstats Display a stream of a containers' resource usage statisticsstop Stop a running containertag Tag an image into a repositorytop Lookup the running processes of a containerunpause Unpause a paused containerversion Show the Docker version informationwait Block until a container stops, then print its exit code
Run 'docker COMMAND --help' for more information on a command.
1、镜像
docker pull NAME[:TAG] #从网络上下载镜像,如果不指定TAG默认下载latest
docker pull dl.dockerpool.com:5000/ubuntu #从dockerpool镜像源下载最新的ubuntu镜像
docker images #列出本地主机上已有的镜像
docker inspect <IMAGE ID> #获取该镜像的详细信息
docker inspect -f {{".Author"}} <IMAGE ID> #使用-f参数,获取镜像的Author信息
docker search TEAM #搜索远程仓库中共享的镜像,默认搜索Docker Hub官方仓库中的镜像
docker search --automated=false/--no-trunc=false/-s, --stars=0 #仅显示自动创建的镜像/输出信息不截断显示/指定显示评价为指定星级以上的镜像
docker rmi <IMAGE ID> #删除镜像
docker rmi -f <IMAGE ID> #强制删除镜像
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] #提交成为一个新的镜像 -m 提交信息、-a 作者信息、 -p 提交是暂停容器运行
cat ubuntu-14.04-x86_64-minimal.tar.gz | docker import - ubuntu:14.04 #从模板中导入镜像
docker load --input ubuntu_14.04.tar 或 docker load ubuntu_14.04.tar #导入镜像到本地
docker push NAME[TAG] #上传镜像到仓库
2、容器
docker create -it <IMAGE ID> #新建一个未运行的容器
docker run <IMAGE ID> #新建并启动容器
docker run -t/-i <IMAGE ID> #-t让Docker分配一个伪终端并绑定到容器的标准输入上,-i标准输入保持打开
docker run -d <IMAGE ID> #守护态运行容器
docker ps #显示正在运行的容器
docker ps -a -q #显示终止状态的容器
docker ps -al #显示所有状态的容器
docker start <CONTAINER ID> #启动容器
docker stop -t=10 <CONTAINER ID> #10s后停止容器
docker restart <CONTAINER ID> #重新启动容器三种进入容器方式
docker attach <CONTAINER ID> #attach方式进入容器
docker exec -ti <CONTAINER ID> /bin/bash #exec方式进入容器
nsenter方式 查看http://my.oschina.net/tpythoner/blog/412391 #nsenter方式进入容器docker rm <CONTAINER ID> #删除容器
docker rm -f <CONTAINER ID> #强制删除容器
docker export <CONTAINER ID> > container.tar #保存容器到container.tar
cat container.tar | docker import - test/unbuntu:v1.0 #导入生成新的容器
未完待续.......