删除脱机docker容器中的文件

时间:2017-03-23 06:18:41

标签: docker lucene

我正在使用以下docker文件:https://github.com/zanata/zanata-docker-files

运行./zanata-server/runapp.sh后,它启动了两个docker容器:

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                    NAMES
654580794e7c        zanata/server:latest   "/opt/jboss/wildfl..."   18 seconds ago      Up 17 seconds       0.0.0.0:8080->8080/tcp   zanata
311f3379635e        mariadb:10.1           "docker-entrypoint..."   2 weeks ago         Up 2 weeks          3306/tcp                 zanatadb

停电后,zanata服务器容器坏了,它留下了一些Lock文件,我无法再启动它:

org.zanata.exception.ZanataInitializationException: Lucene lock files found. Check if Zanata is already running. Otherwise, Zanata was not shut down cleanly: delete the lock files: [/var/lib/zanata/indexes/org.zanata.model.
HTextFlowTarget/write.lock, /var/lib/zanata/indexes/org.zanata.model.HProjectIteration/write.lock, /var/lib/zanata/indexes/org.zanata.model.HProject/write.lock]

如何删除锁定文件?

1 个答案:

答案 0 :(得分:1)

好吧,我认为我需要在容器离线时删除文件,但实际上我需要运行容器,之后我可以连接到它并运行命令,就像我在普通服务器上一样。

主要解决方案:

sudo docker exec -it 654580794e7c bash

这允许我在容器上执行命令:

[jboss@654580794e7c ~]$ ls
wildfly

整个过程,如果你想看到:

zanata@zanata:~/docker/zanata-docker-files-platform-4.1.1/zanata-server$ sudo docker ps
[sudo] password for zanata:
CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                    NAMES
654580794e7c        zanata/server:latest   "/opt/jboss/wildfl..."   17 minutes ago      Up 17 minutes       0.0.0.0:8080->8080/tcp   zanata
311f3379635e        mariadb:10.1           "docker-entrypoint..."   2 weeks ago         Up 2 weeks          3306/tcp                 zanatadb
zanata@zanata:~/docker/zanata-docker-files-platform-4.1.1/zanata-server$ sudo docker exec -it 654580794e7c bash
[jboss@654580794e7c ~]$ ls
wildfly
[jboss@654580794e7c ~]$ cd /var/lib
[jboss@654580794e7c lib]$ ls
alternatives  games      machines  rpm        systemd  zanata
dbus          initramfs  misc      rpm-state  yum
[jboss@654580794e7c lib]$ cd zanata/indexes
[jboss@654580794e7c indexes]$ ls -lh
total 28K
drwxr-xr-x 2 jboss jboss 4.0K Mar  2 13:14 org.zanata.model.HAccount
drwxr-xr-x 2 jboss jboss 4.0K Mar  2 13:14 org.zanata.model.HGlossaryEntry
drwxr-xr-x 2 jboss jboss 4.0K Mar  2 13:14 org.zanata.model.HGlossaryTerm
drwxr-xr-x 2 jboss jboss 4.0K Mar  2 13:30 org.zanata.model.HProject
drwxr-xr-x 2 jboss jboss 4.0K Mar  2 13:30 org.zanata.model.HProjectIteration
drwxr-xr-x 2 jboss jboss 4.0K Mar  3 07:23 org.zanata.model.HTextFlowTarget
drwxr-xr-x 2 jboss jboss 4.0K Mar  2 13:14 org.zanata.model.tm.TransMemoryUnit
[jboss@654580794e7c indexes]$ cd org.zanata.model.HTextFlowTarget/
[jboss@654580794e7c org.zanata.model.HTextFlowTarget]$ ls
_0.cfe  _0.cfs  _0.si  segments_2  write.lock
[jboss@654580794e7c org.zanata.model.HTextFlowTarget]$ rm write.lock
[jboss@654580794e7c org.zanata.model.HTextFlowTarget]$ ls
_0.cfe  _0.cfs  _0.si  segments_2
[jboss@654580794e7c org.zanata.model.HTextFlowTarget]$ cd .
[jboss@654580794e7c org.zanata.model.HTextFlowTarget]$ cd ..
[jboss@654580794e7c indexes]$ cd org.zanata.model.HProject
[jboss@654580794e7c org.zanata.model.HProject]$ ls
_0.cfe  _0.cfs  _0.si  segments_2  write.lock
[jboss@654580794e7c org.zanata.model.HProject]$ rm write.lock
[jboss@654580794e7c org.zanata.model.HProject]$ cd ..
[jboss@654580794e7c indexes]$ cd org.zanata.model.HProjectIteration/
[jboss@654580794e7c org.zanata.model.HProjectIteration]$ ls
_0.cfe  _0.cfs  _0.si  segments_2  write.lock
[jboss@654580794e7c org.zanata.model.HProjectIteration]$ rm write.lock
[jboss@654580794e7c org.zanata.model.HProjectIteration]$ ^C
[jboss@654580794e7c org.zanata.model.HProjectIteration]$ exit
zanata@zanata:~/docker/zanata-docker-files-platform-4.1.1/zanata-server$