为了处理容器关闭后数据消失的问题,
我正在尝试实现一个命令来挂载持久卷。这样,人们就可以积极地交换容器(用于升级等),而不必担心数据丢失。
root@docker-ubuntu-9:~/apache2-Docker# docker run -it -d -p 9000:9000 -p 8000:8000 -P --name mavenLOG -v /root/apache2-Docker/mavenLOG/:/var/log maven-apache2-test02
27125546z622992f301788c49ab99279cfe71e30a399b26bbc8a5c83050cd56c
root@docker-ubuntu-9:~/apache2-Docker#
root@docker-ubuntu-9:~/apache2-Docker# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
27125546z622 maven-apache2-test02 "/usr/bin/supervisord" 16 seconds ago Exited (2) 16 seconds ago mavenLOG
想:
(1)主机有此文件夹
root@docker-ubuntu-9:~/apache2-Docker# ls
all-in-one mavenLOG
(2)容器/var/log
在应用程序启动时进行写入
(3)我希望新容器尊重已经存在的数据,不覆盖或替换,而是从那时起进行读写。
docker run -it -d -p 9000:9000 -p 8000:8000 maven-apache2-test02
(4)我们有一些正在使用的端口,我曾经在持久命令之前用“ ”来生成这些端口
但容器却一直死机。我到底做错了什么?
Docker 中是否仅仅允许卷/文件夹映射?我不需要在容器上安装任何新卷。
[更新:]
root@docker-ubuntu-9:~# docker logs 27125546z622
/usr/lib/python2.7/dist-packages/supervisor/options.py:295: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
但这解决了它,
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven# docker run -it -d -p 9000:9000 -p 8000:8000 -P --name mavenLOG -v /root/apache2-Docker/mavenLOG/:/var/log maven-apache2-test02 /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
06eff95ea56bfe5333e5b7bc0420530fb879bd922ff13b11435e19fac734eb31
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven#
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven#
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
06eff95ea56b maven-apache2-test02 "/usr/bin/supervisord" 4 seconds ago Up 3 seconds 0.0.0.0:9000->9000/tcp, 0.0.0.0:8000->8000/tcp mavenLOG
那么现在我的“日志”将填充容器的“/var/log”吗?