我让Java应用程序将一些输出文件写入用户主目录。我为这个Java应用程序构建了一个docker镜像,并运行了docker容器。我还将日志添加到我的程序中,以查看文件保存的位置。
Writing the metadata to the file path /root/39fd75837c864a68a8db42442d4401fa.txt
当我运行docker run -it imageId bash并试图访问容器中的上述文件时,却无法找到它。
这些文件保存在哪里,以及如何访问docker容器中的这些文件?
我已经创建了两个docker容器,并尝试在ubuntu、debian和一些软件包上安装一些应用程序,如- mc、ping、traceroute..但每当我从容器中退出时,我就失去了那里的一切。有什么docker命令可以保存我的配置吗?
root@ubuntu:/tmp# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
debian latest 2b98c9851a37 4 we
我制作了这个PoC (概念证明)代码,以显示我正在处理的问题。
项目结构:
# ls -R docker_codes/
docker_codes/:
docker-compose.yml dockerfile
文档:
FROM ubuntu
RUN apt-get update
RUN apt-get install -y python3
RUN export export LC_ALL="en_US.UTF-8"
RUN python3 -c "print (u'voil\u00e0')"
docker.compose.yml
version
我知道我可以将postgres图像的默认文件夹更改为指向卷--在这种情况下,卷显然将保持不变。但我没有这么做,因为我想了解这个图像的默认行为。
所以我就跑了:
# in one terminal
docker pull postgres
# as a foreground process:
docker run -P --name dev_db postgres
# in another terminal
docker run --rm -it --link dev_db:dev_db /bin/bash
# in this container, I created some databas