1、centos安装docker
yum list docker //查看是否有docker安装包
yum install docker
2、安装docker-compose
#下载
sudo curl -L https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
#安装
chmod +x /usr/local/bin/docker-compose
#查看版本
docker-compose version
3、
下载一个demo项目,
导入项目
//pom.xml里添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
//类新建一个VistorController
@RestController
public class VisitorController {
@Autowired
private VisitorRepository repository;
@RequestMapping("/")
public String index(HttpServletRequest request) {
String ip=request.getRemoteAddr();
Visitor visitor=repository.findByIp(ip);
if(visitor==null){
visitor=new Visitor();
visitor.setIp(ip);
visitor.setTimes(1);
}else {
visitor.setTimes(visitor.getTimes()+1);
}
repository.save(visitor);
return "I have been seen ip "+visitor.getIp()+" "+visitor.getTimes()+" times.";
}
}
再pom.xml添加这句代码,然后再Appliction的子包或是同级目录加入这个控制器
//pom.xml添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
//application.properties 添加配置
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true
Linux快捷键
cd .. //返回上一级目录
rm -f file //删除文件
mv dir1 dir2 //重命名或移动
systemctl start docker.service //启动一个服务
ps -ef | grep docker //查看进程
yum -y remove docker //卸载yum安装的
wegt http: //下载文件
启动docker-compse
docker-compose up
vim 按esc可以进行选择
:输入代码
i编写