1编辑Dockerfile文件
FROM openjdk:8-jdk-alpine
COPY ./config /platform/iot-manage/config
WORKDIR /platform/iot-manage
COPY jar/iot-manage-0.0.1.jar /platform/iot-manage/iot-manage-0.0.1.jar
ENTRYPOINT ["sh","-c","java ${JVM_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /platform/iot-manage/iot-manage-0.0.1.jar ${JAVA_OPTS}"]
compose文件
version: '2'
services:
platform-file:
image: bd-platform-data-security-server:v1.0.8
container_name: bd-platform-data-security-server
network_mode: host
restart: always
environment:
JVM_OPTS: " -Xms1024M -Xmx2048M"
JAVA_OPTS: "--config-user=platform --config-password=1234abcD --eureka-urls=1111111"
volumes: #映射目录和文件 主机文件(目录) : docker文件(目录)
- /etc/localtime:/etc/localtime:ro #映射始终配置
- /etc/hosts:/etc/hosts:ro #映射hosts文件
- /home/tsp/application.properties:/application.properties:ro #映射 application.properties 配置文件
- /usr/local/logs/tsp:/usr/local/logs #映射log目录
- /run/media/root/data/tsp/down:/data/down
2制作镜像
docker build -t imagename Dockerfilepath
docker build -t tsp_20211011 .
3导出镜像
docker save > my_docker.tar docker_name:docker_version
docker save > tsp.tar tsp_20211011
4装载镜像
docker load < tsp_20211011.tar
5查看镜像情况
docker images -a
docker images
docker rmi 删除镜像
docker-compose命令启动镜像
启动:docker-compose -f tsp-compose.yml up -d
停止:docker-compose -f tsp-compose.yml down
查看log:docker-compose -f --tail=100 tsp-compose.yml logs
进入docker容器
docker exec -it 5e21c65931ea93f5e70 /bin/sh
容器操作
docker restart
docker start
docker stop
docker rm 删除镜像
日志
docker logs -f --tail=100 0b5079cec103