安装
yum install docker
二级目录
三级目录
配置国内仓库
cat > /etc/docker/daemon.json <<EOF
{
“registry-mirrors”: [“https://0c6u5r6d.mirror.aliyuncs.com”],
“insecure-registries”:[“172.24.239.203”]
}
EOF
systemctl daemon-reload
systemctl restart docker
基本使用
镜像与容器嘚导入导出
images
docker save > nginx.tar nginx:latest
docker load < nginx.tar
container
docker export -o nginx-test.tar nginx-test
docker import nginx-test.tar nginx:imp
容器提交
docker ps -a 查看终止的容器
docker commit -a “runoob.com” -m “my apache” a404c6c174a2 mymysql:v1
查看修改容器的配置
vi /var/lib/docker/containers/+id/hostconfig.json
容器的启动和开机自启
docker run --privileged -itd -u 0 --name robot --net=host 172.24.239.203/auto/robot:latest /usr/sbin/init
docker update --restart=always xxx
docker run --restart=always --privileged -itd -u 0 --name robot --net=host -v /home/version:/home/KPQA_Plat/caseTXT/version/ -v /home/version:/home/Report/ 172.24.239.203/auto/robot:latest /usr/sbin/init
推送镜像到仓库
docker login --username=zhongXX 172.24.239.203
docker commit -a “zhonggaopeng” -m “web” 065e45fac481 robot:v3
docker tag bf145db7e900 172.24.239.203/auto/robot:v3
docker push 172.24.239.203/auto/robot:v3
补充
打包
tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/mnt --exclude=/var/cache --exclude=/usr/share/{foomatic,backgrounds,perl5,fonts,cups,qt4,groff,kde4,icons,pixmaps,emacs,gnome-background-properties,sounds,gnome,games,desktop-directories} --exclude=/var/log -zcvf /mnt/CentOS7-BaseImage.tar /
安装
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
docker import CentOS7-BaseImage.tar centos7
docker network create --driver bridge --subnet=192.168.200.0/24 --gateway=192.168.200.1 mynet
docker network rm mynet
–network=mynet --ip 172.18.12.1
docker run --privileged -itd -u 0 -p 9223:9223 -p 80:80 -p 3306:3306 --network=mynet --ip 192.168.200.100 --name xx centos7:latest /bin/bash
iptables -t nat -A POSTROUTING -p tcp -s 192.168.200.100 -j SNAT –to-source 192.168.124.5
停止docker service
systemctl stop docker
#关闭docker0网卡(如果没有ifconfig,则需要先安装(yum install net-tools))
ifconfig docker0 down
#删除docker0网卡(如果没有brctl,则需要先安装(yum install bridge-utils))
brctl delbr docker0
启动游戏