- linux
- 普通用户使用sudo命令设置不需要输入密码:
- vim /etc/sudoers
- 找到root,在下面输入新用户,例:
- szh ALL=(ALL) NOPASSWD:ALL
- yum
- 使用yum时可能出现no package *** avaliable,这是yum需要更新,需要执行 sudo yum update
- tar
- grep
- 筛选进程ID
- docker ps -a |grep Up |awk '{print$1}' |xargs docker stop
- ps -a 所有docker的进程
- |grep Up 筛选是Up状态的进程
- |awk '{print$1}' 打印第一列的值
- |xargs docker stop 将筛选出的数据进行操作
- docker
- 卸载docker所有内容:
- sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
- 安装docker
- 安装依赖:
- sudo yum install -y yum-utils
- sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
- 安装docker引擎
- sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- 开始并验证docker
- sudo systemctl start docker
- sudo docker run hello-world
- docker镜像
- docker images
- 删除镜像:docker rmi 镜像ID 前提是得把服务停掉
- docker -nginx
- 先启动docker: sudo systemclt start docker
- 下载nginx镜像:sudo docker pull nginx
- 查看docker镜像: sudo docker images
- 启动docker-nginx容器:docker run -d -p8080:80 --name=nginx nginx
- -d后台运行
- -p 外部端口8080映射到容器80端口
- --name 服务别名
- 常用命令
- docker run 启动命令 状态为Up
- docker stop 停止命令 状态为Exited
- docker rm 删除镜像命令
- docker -nacos
- docker pull nacos/nacos-server:1.3.1
- docker run -d -p 8848:8848 -p 9848:9848 --name nacos --env MODE=standalone --env SPRINGDATASOURCEPLATFORM=mysql --env MYSQLSERVICEHOST=192.168.35.131 --env MYSQLSERVICEPORT=3306 --env MYSQLSERVICEDB_NAME=nacos_config --env MYSQLSERVICEUSER=root --env MYSQLSERVICEPASSWORD=123456 nacos/nacos-server:1.3.1
- docker -mysql
- docker pull nacos:5.7
- 连接mysql后创建数据库
- CREATE DATABASE IF NOT EXISTS nacos_config
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_bin ; - 执行sql脚本:nacos/nacos-db.sql at master · alibaba/nacos · GitHub
- docker -redis
- docker pull redis
- docker run -p6379:6379 -d --name=redis redis
- docker -oracle
- docker -jenkins
- docker pull jenkins:2.32.2-alpine
- docker run -d --restart=always -p 8081:8080 -v /usr/lib/jvm/java-8-openjdk-amd64/bin/java:/usr/lib/jvm/java-8-openjdk-amd64/bin/java -v /usr/lib/jvm/java-8-openjdk-amd64/:/usr/lib/jvm/java-8-openjdk-amd64/ -v /home/jenkins/:/var/jenkins -v /var/run/docker.sock:/var/run/docker.sock -e JAVA_OPTS='-Duser.timezone=Asia/Shanghai' -u root --name jenkins_01 jenkins:2.32.2-alpine
- docker run -d --name jenkins -p 9999:8080 -p 8888:8888 -p 50000:50000 -v /usr/local/src/jdk/jdk1.8:/usr/local/src/jdk/jdk1.8 -v /opt/apache-maven-3.5.0:/opt/apache-maven-3.5.0 -v /home/jenkinshome:/var/jenkinshome jenkins:2.32.2-alpine
- 查看admin密码:
- docker exec -it jenkins_01 /bin/bash
- cat /var/jenkins_home/secrets/initialAdminPassword