安装cnpm:
npm cache clean --force
npm cache verify
npm config get registry
npm install -g cnpm --registry=https://registry.npmmirror.com
检查服务器版本和内核版本
cat /etc/redhat-release
uname -r
daoker卸载:
systemctl stop docker
systemctl stop docker.socket # 存在socket激活时需额外执行:ml-citation{ref="2,5" data="citationList"}
yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin:ml-citation{ref="1,3" data="citationList"}
rm -rf /var/lib/docker # 核心存储目录
rm -rf /var/lib/containerd # 容器运行时数据
rm -rf /etc/docker # 配置文件:ml-citation{ref="3,4" data="citationList"}
yum autoremove # 自动移除孤立依赖
yum clean all # 清理yum缓存:ml-citation{ref="3,4" data="citationList"}
安装docker:
yum install docker-ce -y
systemctl start docker
systemctl enable docker
docker build -t csc-backend .
部署nginx 映射前端:
docker run -d -p 8007:8007 -v /root/build/csc/dist:/usr/share/nginx/html -v /root/build/csc/nginx.conf:/etc/nginx/nginx.conf -v /root/build/csc/conf.d/default.conf:/etc/nginx/conf.d/default.conf --name csc-front
docker run -d -p 8007:8007 -v /root/build/csc/dist:/usr/share/nginx/html --name csc-front 605c77e624dd
docker pull mysql:latest
docker run -d -p 3307:3307 -v /root/build/docker/conf/mysql/conf.d:/etc/mysql/conf.d -v /root/build/csc/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d -e MYSQL_ROOT_PASSWORD=********* --name mysql mysql:latest
docker核心日志:
journalctl -u docker.service
手动添加阿里云镜像源(替代官方源)
cat > /etc/yum.repos.d/docker-ce.repo <<EOF
[docker-ce-stable]
name=Docker CE Stable
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/\$releasever/\$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
EOF
网络相关:
docker network ls
docker network inspect <网络名称或ID>
docker network create --driver bridge --subnet 103.148.0.0/16 --gateway 103.148.0.1 mybridge2
docker network rm <网络名称或ID>
docker run -p 80:80 --name test3 hello-world --network mybridge
docker run hello-world