docker
docker是利用Namespace, Cgroup和联合文件三大机制来保证实现
- 安装 docs.docker.com/engine/inst…
- 启动
sudo systemctl start docker - 开机自启
sudo systemctl enable docker
镜像
docker pull [image][:tag]拉取镜像 -docker pull busybox:latesttdocker images查看所有镜像docker images | grep busybox列出所有镜像并过滤出busybox
docker tag [sourceImage]:[tag] [newImage]:[tag]给镜像取一个新名docker tag busybox:latest mybusybox:latest复制busybox:latest,粘贴为mybusybox:latest
docker rmi [image]:[tag]或docker rmi [imageid]删除镜像
容器
docker ps查看运行的容器docker ps -a查看所有容器docker run -itd --name=cRedis -p 6379:6379 redis:alpine运行容器,===docker create + docker startdocker exec -it container(name|id) /bin/bash进入容器内部docker start|stop|restart container(name|id)启动|停止|重启容器docker rm -f container(name|id)删除容器
常用参数
-i运行容器,交互式-d后台守护方式运行-t终端-phostPort:containerPort 宿主机端口与容器端口映射-vhostDir:containerDir 挂载目录--name=customerContainerName给容器添加名称--restart=alwaysdocker重启的时候,该容器总是自动重启