社区:
http://www.dockerinfo.net/rancher
https://www.kubernetes.org.cn/
1,docker安装配置
环境 centos7.2
yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum-config-manager --enable docker-ce-edge yum clean all && yum makecache yum install -y docker-ce.x86_64
配置加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://50208f86.m.daocloud.io systemctl daemon-reload && systemctl start docker curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://8c593af7.m.daocloud.io systemctl daemon-reload && systemctl start docker
导入导出镜像
docker save images > aa.tar.gz
docker load -qi nginxplus.tar
docker常用操作
4,docker常用命令
镜像操作:
搜索 docker search
获取 docker pull
查看 docker images
删除 docker rmi
镜像导入导出:
docker export id > cenos6.tar cat centos.tar|docker import - centos6
运行镜像:
docker run centos echo "hello word"#在docker容器中运行hello world! docker run centos yum install ntpdate#在容器中安装ntpdate的程序
提交刚修改的容器为镜像:
docker commit 2313132 centos:v1 docker commit -m "My Nginx" fa1529ebdb96 mynginx:v1
容器id
关闭启动删除容器:
docker stop id docker start id #docker start 5c4a428e7335 docker rm -f id docker run --name lannydocker -it centos /bin/bash docker run --rm --name lannydocker -it centos /bin/bash
映射端口:
docker run -d -p 80:80 -p 8022:22 centos:v2
镜像--运行--exit--后台运行--再次进入
方法1,
docker start id
docker attach b83fff0e6cdc
对于nginx可能会进入失败
使用nscenter进去,yum install util-linux –y
方法2,脚本方法重新进容器
docker start id
./in.sh mynginx
其它命令:
容器停止后就自动删除: docker run --rm centos /bin/echo "One" 杀死所有正在运行的容器: docker kill $(docker ps -a -q) 删除所有已经停止的容器: docker rm $(docker ps -a -q) 删除所有未打标签的镜像 docker rmi $(docker images -q -f dangling=true)
进入容器脚本:in.sh
#!/bin/bash # Use nsenter to access docker docker_in(){ NAME_ID=$1 PID=$(docker inspect -f "{{ .State.Pid }}" $NAME_ID) nsenter -t $PID -m -u -i -n -p } docker_in $1