Centos服务器配置与部署过程
安装与配置docker
1、检查内核版本,必须是3.10及以上 uname -r 2、安装docker yum install docker 3、输入y确认安装 4、启动docker [root@localhost ~]# systemctl start docker [root@localhost ~]# docker -v Docker version 1.12.6, build 3e8e77d/1.12.6 5、开机启动docker [root@localhost ~]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. 6、停止docker systemctl stop docker
docker配置加速器
#打开文件地址 vim /etc/docker/daemon.json #腾讯服务器加速地址加入 { "registry-mirrors": ["https://mirror.ccs.tencentyun.com"] } #阿里云的服务器请查看:阿阿里云服务器下的容器镜像服务,选择容器加速器,里面有教程 { "registry-mirrors": ["https://xeizattv.mirror.aliyuncs.com"] } #https://xeizattv.mirror.aliyuncs.com wq保存退出: 执行命令生效: systemctl daemon-reload systemctl restart docker
安装docker-compose
#下载 curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
#设置 chmod +x /usr/local/bin/docker-compose #验证安装是否成功 docker-compose version
docker-compose 配置
#在有docker-compose 的目录下 #启动 docker-compose up -d #关闭 docker-comose down #查看日志 docker-compose logs
nacos 安装
#clone项目 git clone https://github.com/nacos-group/nacos-docker.git cd nacos-docker #单机模式 docker-compose -f example/standalone-mysql.yaml up -d #查看日志 docker-compose -f example/standalone-mysql.yaml logs -f #控制台 http://地址:8848/nacos
安装Mysql
#docker-compose version: '3.1' services: db: # 目前 latest 版本为 MySQL8.x image: mysql restart: always environment: MYSQL_ROOT_PASSWORD: 123456 command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 ports: - 3306:3306 volumes: - ./data:/var/lib/mysql # MySQL 的 Web 客户端 adminer: image: adminer restart: always ports: - 8881:8881
安装redis
version: '3.1' services: redis: image: redis container_name: redis restart: always command: redis-server --requirepass 123456 #设置密码 ports: - 6379:6379 volumes: - ./redis_data:/data
配置tomcat
version: '3.1' services: tomcat: restart: always image: tomcat container_name: tomcat ports: - 8080:8080 volumes: - ./webapps:/usr/local/tomcat/webapps environment: TZ: Asia/Shanghai
配置 nexus
version: '3.1' services: nexus: restart: always image: sonatype/nexus3 container_name: nexus ports: - 8081:8081 volumes: - nexus-data:/nexus-data #统一配置了数据卷 在/var/lib/docker/volumes/ 目录下可以找到数据 volumes: nexus-data:
交互式进入容器
docker exec -it b410b15951e4 bash
查看容器日志
sudo docker logs -f -t --tail 100 16154cfbafcb
来源:https://www.cnblogs.com/chenhanhao/p/12536500.html