4
docker 挂载的一些问题,困扰已久,求解答
source link: https://www.oschina.net/question/4420787_2325084
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
docker 挂载的一些问题,困扰已久,求解答
version: '2'
services:
# 自定义服务名
gateway:
# 总起重启
#restart: always
image: gateway:0.0.1 #指定镜像名称
build: . #指定Dockfile所在路径
container_name: gateway #指定启动容器名称
volumes:
- /etc/localtime:/etc/localtime:ro #同步宿主机与容器时间,ro代表readonly只读
- ../gateway-lib:/home/gateway/lib
- ./:/strive/gateway
- ./logs:/logs
# 端口映射
ports:
- 8000:8000
- 20880:20880
#配置网络通信
network_mode: "bridge"
environment:
# 指定时区
- TZ="Asia/Shanghai"
- JAVA_OPTS=-Xms1024m -Xmx1024m -XX:MetaspaceSize=256M -XX:MaxDirectMemorySize=512M -Xss256k -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8
主机的logs是个空目录
- 容器运行,容器里的spring日志会被挂载到主机的logs目录里,但是删除容器,主机的logs目录的日志文件也会被删掉
- 容器运行,容器里的spring日志会被挂载到主机的logs目录里,此时进入容器,在容器的日志目录里创建a.txt文件,同样会被挂载到主机目录,但是此时删除容器,主机里的内容却不会被清空
对于以上两点已经困惑很久,希望有人能帮忙解答一下!!!!!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK