Docker technical notes
2015-12-25 13:11
671 查看
1. Mount a host directory into the docker container
sudo docker run -i -t -v /home/ubuntu:/mnt/ubuntu d55e /bin/bash
2. When pressing "ctrl + p + q" and the terminal returns to the parent shell, the container switched into a "stopped" status but still remains in the system background.
An improper "kill/stop" or "commit" to an container may result in a bunch of dangling containers and untagged images, which can quickly exhaust system resources (space/memory)
Solution:
杀死所有正在运行的容器
复制代码代码如下:
docker kill $(docker ps -a -q)
删除所有已经停止的容器
复制代码代码如下:
docker rm $(docker ps -a -q)
删除所有未打 dangling 标签的镜像
复制代码代码如下:
docker rmi $(docker images -q -f dangling=true)
删除所有镜像
复制代码代码如下:
docker rmi $(docker images -q)
为这些命令创建别名
复制代码代码如下:
# ~/.bash_aliases
# 杀死所有正在运行的容器.
alias dockerkill='docker kill $(docker ps -a -q)'
# 删除所有已经停止的容器.
alias dockercleanc='docker rm $(docker ps -a -q)'
# 删除所有未打标签的镜像.
alias dockercleani='docker rmi $(docker images -q -f dangling=true)'
# 删除所有已经停止的容器和未打标签的镜像.
alias dockerclean='dockercleanc || true && dockercleani'
3. If a dangling image is the base layer of other tagged images, then command "docker rmi $(docker images -q -f dangling=true)" will fail.
See layer structure of iamges:
sudo docker images -tree
Option 1:
Delete all Images:
sudo docker rmi -f $(sudo docker images -a)
4. Push a repository/image to docker hub
sudo docker push repository_name:tag
5. Docker Image Rename
7. Remove unwanted image tags
docker rmi repository/image_name:[tag]
(Note: Square Bracket is a notation for optional parameters)
output: Untagged: furaoing/ipsexl2tpd:latest (which means the this image has been untagged "xxxx", this tag had been just deleted)
sudo docker run -i -t -v /home/ubuntu:/mnt/ubuntu d55e /bin/bash
2. When pressing "ctrl + p + q" and the terminal returns to the parent shell, the container switched into a "stopped" status but still remains in the system background.
An improper "kill/stop" or "commit" to an container may result in a bunch of dangling containers and untagged images, which can quickly exhaust system resources (space/memory)
Solution:
杀死所有正在运行的容器
复制代码代码如下:
docker kill $(docker ps -a -q)
删除所有已经停止的容器
复制代码代码如下:
docker rm $(docker ps -a -q)
删除所有未打 dangling 标签的镜像
复制代码代码如下:
docker rmi $(docker images -q -f dangling=true)
删除所有镜像
复制代码代码如下:
docker rmi $(docker images -q)
为这些命令创建别名
复制代码代码如下:
# ~/.bash_aliases
# 杀死所有正在运行的容器.
alias dockerkill='docker kill $(docker ps -a -q)'
# 删除所有已经停止的容器.
alias dockercleanc='docker rm $(docker ps -a -q)'
# 删除所有未打标签的镜像.
alias dockercleani='docker rmi $(docker images -q -f dangling=true)'
# 删除所有已经停止的容器和未打标签的镜像.
alias dockerclean='dockercleanc || true && dockercleani'
3. If a dangling image is the base layer of other tagged images, then command "docker rmi $(docker images -q -f dangling=true)" will fail.
See layer structure of iamges:
sudo docker images -tree
Option 1:
Delete all Images:
sudo docker rmi -f $(sudo docker images -a)
4. Push a repository/image to docker hub
sudo docker push repository_name:tag
5. Docker Image Rename
[code]docker tag 1cf76 myUserName/imageName:0.1.0
7. Remove unwanted image tags
docker rmi repository/image_name:[tag]
(Note: Square Bracket is a notation for optional parameters)
output: Untagged: furaoing/ipsexl2tpd:latest (which means the this image has been untagged "xxxx", this tag had been just deleted)
相关文章推荐
- Docker 管理工具
- docker1.9 network跨主机安装
- 使用Compose变量定制Docker网络
- 使用Compose变量定制Docker网络
- Docker核心技术
- Docker核心技术
- 【Docker技术入门与实战】存出和载入镜像
- docker中文 docker手册 docker教程
- 深刻理解Docker镜像大小
- Docker Image管理学习笔记
- Allen 谈 Docker 系列
- 深入分析Docker镜像原理
- python3操作Docker Remote API
- docker命令整理,python,环境测试
- 阿里云Centos6.6安装配置docker
- Docker run 命令
- Docker实战(九):Docker安装ELK环境
- 将要改变IT世界的的docker技术是什么?
- Dockerfile(SSH+iperf)
- 进入docker容器之nsenter脚本