【docker】最常用几个命令
查找镜像、查看本地镜像、查看容器、创建容器
1. 最常用命令
查找镜像
docker search centos
查看本地镜像:
docker images
查看容器
docker ps //只看活着的
docker ps -a //死活都看
.修改/etc/docker/daemon.json完成后reload配置文件 重启docker服务,设置开机启动
systemctl daemon-reload && systemctl restart docker.service && systemctl enable docker.service
c.查看状态
systemctl status docker -l
d.查看服务
docker info
创建容器
docker container run
--name=mysqlofmine(container的名字)
--publish=3306:3306
--volume=/data/mysql/:/var/lib/mysql/
--restart=always
--env=MYSQL_ROOT_PASSWORD=123456
-d centos/mysql-57-centos7(image的名字)
把镜像(例如haproxy.tar)本地包导入到本地docker镜像
docker load -i haproxy.tar
docker images
//查看有该镜像
pull 镜像之前阿里云加速
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json «-‘EOF’ { “registry-mirrors”: [“https://ji1i86y7.mirror.aliyuncs.com”] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
导入haproxy镜像
# ls /usr/local/kubernetes/install
haproxy.tar
keepalive.tar
kubeadm-basic.images.tar.gz
load-images.sh
start.keep.tar.gz
docker load -i haproxy.tar
导入kubeadm镜像群
先解压缩
tar xvzf kubeadm-basic.images.tar.gz
然后,修改load-images.sh专门用来导入kubeadm-basic.images.tar.gz里的多个镜像:
#!/bin/bash
cd /usr/local/kubernetes/install/kubeadm-basic.images
ls /usr/local/kubernetes/install/kubeadm-basic.images | grep -v load-images.sh > /tmp/k8s-images.txt
for i in #( cat /tmp/k8s-images.txt )
do
docker load -i $i
done
rm -fr /tmp/k8s-images.txt
最后执行导入
./load-images.sh
Written on July 4, 2020