![关注抖音创业](https://img.kancloud.cn/c5/ce/c5ced2ea291122851697114ca415ff95_1125x1680.png) [TOC] # 创建和删除volume 查看volume 帮助命令`docker volume -h` ``` Commands: create Create a volume inspect Display detailed information on one or more volumes ls List volumes prune Remove all unused local volumes rm Remove one or more volumes ``` 创建:`docker volume create --name v1 ` 删除:`docker volume rm v1` 查看详情:`docker volume inspect v1` ``` docker volume create my-vol #创建数据卷 docker volume ls #查看有哪些卷 docker volume inspect my-vol #查看卷详情 docker rm -f web #强制删除运行中的容器 docker volume rm my-vol #删除卷 docker volume prune #清理无用的卷 docker ps -s #可以查看容器的大小是没有增加的 ``` # 案例 > docker中使用sqllite数据库,数据库以目录方式挂载 ## Dockerfile ``` #拉取镜像 FROM openjdk:8 #调整时区 #上海时区 ENV TZ=PRC RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # sqllite RUN sudo apt-get -y update RUN sudo apt-get -y upgrade RUN sudo apt-get install -y sqlite3 libsqlite3-dev #获取jar包 ARG JAR_FILE=target/*.jar #目录不存在会自动创建 cd //opt/land-monito WORKDIR /opt/land-monitor #复制jar包 COPY ${JAR_FILE} land-monitor.jar COPY src/main/resources/db/monitor.db /opt/land-monitor/monitor.db RUN chmod 644 /opt/land-monitor/monitor.db #监听5001端口 EXPOSE 5001 #运行jar包 #java -jar /opt/app/app.jar -Xms256m -Xmx256m CMD ["-Xms256m","-Xmx256m"] ENTRYPOINT ["java","-Dfile.encoding=utf-8","-jar","land-monitor.jar"] ``` # yml配置文件database配置 ``` spring: datasource: url: jdbc:sqlite:/opt/land-monitor/monitor.db username: password: driver-class-name: org.sqlite.JDBC ```