4

docker 挂载的一些问题,困扰已久,求解答

 2 years ago
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 挂载的一些问题,困扰已久,求解答

是榴不是柳 发布于 昨天 11:43
  1. version: '2'
  2. services:
  3. # 自定义服务名
  4. gateway:
  5. # 总起重启
  6. #restart: always
  7. image: gateway:0.0.1 #指定镜像名称
  8. build: . #指定Dockfile所在路径
  9. container_name: gateway #指定启动容器名称
  10. volumes:
  11. - /etc/localtime:/etc/localtime:ro #同步宿主机与容器时间,ro代表readonly只读
  12. - ../gateway-lib:/home/gateway/lib
  13. - ./:/strive/gateway
  14. - ./logs:/logs
  15. # 端口映射
  16. ports:
  17. - 8000:8000
  18. - 20880:20880
  19. #配置网络通信
  20. network_mode: "bridge"
  21. environment:
  22. # 指定时区
  23. - TZ="Asia/Shanghai"
  24. - JAVA_OPTS=-Xms1024m -Xmx1024m -XX:MetaspaceSize=256M -XX:MaxDirectMemorySize=512M -Xss256k -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8

主机的logs是个空目录

  1. 容器运行,容器里的spring日志会被挂载到主机的logs目录里,但是删除容器,主机的logs目录的日志文件也会被删掉
  2. 容器运行,容器里的spring日志会被挂载到主机的logs目录里,此时进入容器,在容器的日志目录里创建a.txt文件,同样会被挂载到主机目录,但是此时删除容器,主机里的内容却不会被清空

对于以上两点已经困惑很久,希望有人能帮忙解答一下!!!!!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK