Docker基础用法

VmWare的网络配置选择NAT模式,CentOS7版本选择7.4以及7.4以后的版本
配置ip地址

cat /etc/sysconfig/network-scripts/ifcfg-ens33  
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes  
IPADDR=192.168.20.21  
GATEWAY=192.168.20.2  
NETMASK=255.255.225.0  
DNS1=8.8.8.8  
DNS2=114.114.114.114  
重启网卡 
systemctl restart network

关闭selinux和防火墙

编辑/etc/selinux/config
将文本中的SELINUX=enforcing,改为SELINUX=disabled

临时关闭:systemctl stop firewalld
防火墙开机关闭:systemctl disable firewalld
开机启动:systemctl enable firewalld
查看状态:systemctl status firewalld

配置网络yum源

cd /etc/yum.repos.d/  
mkdir repos.backup   
find ./ -type f -name "*.repo" | xargs -i mv  {
     }  /etc/yum.repos.d/  
yum -y install wget  

阿里云官方yum源

centos7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

阿里云epol源

wget https://mirrors.aliyun.com/repo/epel-7.repo
清除缓存并更新
yum clean all
yum makecache
yum update

清华大学的docker-ce.repo源

wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
两种方式替换  
将https://download.docker.com/替换成https://mirrors.tuna.tsinghua.edu.cn/docker-ce/
vim docker-ce.repo  
搜索全文进行替换
:%s@https://download.docker.com/@https://mirrors.tuna.tsinghua.edu.cn/docker-ce/@
使用sed进行替换
sed -i 's#https://download.docker.com/#https://mirrors.tuna.tsinghua.edu.cn/docker-ce/#g' /etc/yum.repos.d/docker-ce.repo

安装docker-ce、配置镜像加速器并启动docker服务

yum repolist   
安装docker-ce
yum -y install docker-ce  
配置阿里云镜像加速器
mkdir /etc/docker
vim /etc/docker/daemon.json
{
     
 "registry-mirrors":["https://xxx.mirror.aliyuncs.com"]
}
启动docker服务 
systemctl start docker.service

docker常用命令

docker search 镜像名  从docker hub上搜索镜像 
docker pull  镜像名   下载镜像到本地  或者 docker image pull 
docker images        列出本地镜像  或者 docker image ls (docker image ls --help)
docker image rm 镜像名  删除镜像   或者  docker rmi 镜像名    
docker container ls   列出运行的容器   或者  docker ps 
docker network ls   显示网络类型  ( bridge(默认类型) host  none )
docker run 系列  (docker run --name kvstore1 -d redis:4.0-alpine)  apline   基础版本 
docker inspect  
docker start 容器名  
docker stop 容器名  
docker restart 容器名 
docker kill 容器名 

Docker基础用法_第1张图片

你可能感兴趣的:(Docker,Docker)