相關(guān)命令
- 通用
操作 | 命令 | 示例 |
---|---|---|
查看版本 | docker version | docker version |
查看信息 | docker info | docker info |
查看某命令 help 信息 | docker help [command] | docker help attach |
查看 docker help 信息 | docker --help | docker --help |
- image相關(guān)
操作 | 命令 | 示例 |
---|---|---|
通過容器創(chuàng)建鏡像 | docker commit [container][imageName] | docker commit nostalgic_morse ouruser/sinatra:v2 |
通過dockerfile創(chuàng)建鏡像 | docker build -t [imageName] [pathFile] | docker build -t jdk . |
查看本地所有鏡像 | docker images | docker images |
從 registry 中獲取鏡像(若無指定 tag 名稱,則默認(rèn)使用 latest 這個(gè) 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相關(guān)
操作 | 命令 | 示例 |
---|---|---|
創(chuàng)建 | docker create | docker create testmk12/jdk |
創(chuàng)建并運(yùn)行 | docker run | docker run testmk12/jdk |
創(chuàng)建并運(yùn)行container后進(jìn)入其bash控制臺(tái) | docker run -t -i image /bin/bash | docker run -t -i ubuntu /bin/bash |
創(chuàng)建并運(yùn)行container并讓其在后臺(tái)運(yùn)行逛尚,并端口映射 | docker run -p [port in container]:[port in physical system] -d [image] [command] | docker run -p 3306:3306 -d testmk12/jdk |
查看正在運(yùn)行的所有container信息 | docker ps | docker ps |
查看最后創(chuàng)建的container | docker ps -l | docker ps -l |
停止container | docker stop [container] | docker stop tomcat |
強(qiáng)制停止container | docker kill [container] | docker kill tomcat |
啟動(dòng)container | docker start [container] | docker start jdk |
重啟container | docker restart [container] | docker restart tomcat |
刪除container | docker rm [container] | docker rm tomcat |