docker
基础命令
docker run -it --name XXX centos:latest # 运行容器镜像
docker ps [-a] # -a可查询所有实例,包括已停止的
docker start ID # 启动停止的容器实例
docker attach ID # 使用最近的bash流,进入容器
docker exec -t ID /bin/bash # 新建bash流,进入容器
docker cp LOCAL_PATH ID:/DOCKER_PATH
docker cp ID:/DOCKER_PATH LOCAL_PATH
exit # 停止并退出容器
高级命令
When you kill and remove a Docker container, you're supposed to include the -v param in docker rm, but if you don't do that, the stuff in the volume will presist in the host's filesystem until you rm -rf form /var/lib/docker/volumes/, which can be dangerous if you're not careful.
docker rm -v $(docker ps -q -f status=exited)
清理损坏的或半成品镜像
docker rmi $(docker images -q -f dangling=true)
清理残留的volume
docker volume rm $(docker volume ls -qf dangling=true)
批量启动停止的容器
docker start $(docker ps -q -f status=exited)
拷贝主机目录或文件到容器内。如果files文件夹不存在,则将前者里的所有内容移入files,否则前者移入files
docker cp /root/amazeui-2.5.1/ CONTAINER:/var/www/files
查看容器特定属性
docker inspect --format='{{ .NetworkSettings.IPAddress }}' CONTAINER
查看容器日志
# Show logs since timestamp
$ docker logs --since=2016-03-04T12:00:00 CONTAINER
# Number of lines to show from the end of the logs
$ docker logs --tail=30 CONTAINER
windows平台docker-machine对应的主机和密码docker@192.168.99.100 tcuser
linux远程文件传输命令,有git bash的windows也支持
scp -r amazeui-2.5.1/ root@liteapi.com:/root/
查看内存占用cat /proc/meminfo