--Dockerfile 内容
# 基于哪个镜像
1 FROM java:8
# 将本地文件夹挂载到当前容器
1 VOLUME /tmp
# 复制文件到容器
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 ADD liuxiaofeng-module-system-2.2.0.jar(文件名) liuxiaofeng-module-system.jar(重命名) 2 RUN bash -c 'touch /liuxiaofeng-module-system.jar'
# 声明需要暴露的端口
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 EXPOSE 8687
# 配置容器启动后执行的命令
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/liuxiaofeng-module-system.jar"]
--构建和运行容器
1、下载java8镜像 注:最开始的时候才需要
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker run java /bin/echo 'hello world'
2、构建镜像(在Dockerfile路径下)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker build -t liuxiaofeng-module-system(镜像名称) .(本地路径)
3、运行docker镜像
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker run --name liuxiaofeng-module-system(命名) -d -p 8687:8687(指定端口) liuxiaofeng-module-system(指定镜像)
--删除容器和镜像
1、列出所有容器
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker container ls -a
2、删除容器
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker rm 容器id 注:若提示在运行状态,则 docker kill 容器id
3、列出所有镜像
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker images
4、删除镜像
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker rmi 镜像id
--启动已存在容器
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 docker start 容器id