При запуске docker-compose с упущенным поиском изображения выкидывает ошибку Java - PullRequest
1 голос
/ 26 марта 2019

Учитывая, что у меня есть докеризованное приложение, которое подключается к докерскому образуasticsearch через docker-compose

например:

---
version: '3'
services:
  elasticsearch:
    image: elasticsearch:6.6.1
    environment:
  myapp:
    image: myapp:latest
    build:
      context: .
      dockerfile: Dockerfile
    links:
      - elasticsearch:elasticsearch

Когда я делаю docker-compose up

, я получаюошибка:

elasticsearch_1         | [2019-03-26T14:46:04,345][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
elasticsearch_1         | org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         | Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
elasticsearch_1         |   at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:297) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.node.Node.<init>(Node.java:295) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   ... 6 more
elasticsearch_1         | Caused by: java.io.IOException: failed to obtain lock on /usr/share/elasticsearch/data/nodes/0
elasticsearch_1         |   at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:215) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:267) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.node.Node.<init>(Node.java:295) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   ... 6 more
elasticsearch_1         | Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes/0/node.lock
elasticsearch_1         |   at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
elasticsearch_1         |   at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
elasticsearch_1         |   at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]
elasticsearch_1         |   at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:178) ~[?:?]
elasticsearch_1         |   at java.nio.channels.FileChannel.open(FileChannel.java:292) ~[?:?]
elasticsearch_1         |   at java.nio.channels.FileChannel.open(FileChannel.java:345) ~[?:?]
elasticsearch_1         |   at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:125) ~[lucene-core-7.6.0.jar:7.6.0 719cde97f84640faa1e3525690d262946571245f - nknize - 2018-12-07 14:44:20]
elasticsearch_1         |   at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41) ~[lucene-core-7.6.0.jar:7.6.0 719cde97f84640faa1e3525690d262946571245f - nknize - 2018-12-07 14:44:20]
elasticsearch_1         |   at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45) ~[lucene-core-7.6.0.jar:7.6.0 719cde97f84640faa1e3525690d262946571245f - nknize - 2018-12-07 14:44:20]
elasticsearch_1         |   at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:208) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:267) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.node.Node.<init>(Node.java:295) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.1.jar:6.6.1]
elasticsearch_1         |   at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.1.jar:6.6.1]

1 Ответ

0 голосов
/ 26 марта 2019

Не знаю точно, почему это происходит. Для меня это было связано с обновлением версииasticsearch в файле docker-compose. Мы обновили с image: elasticsearch:6.5 до image: elasticsearch:6.6.1, и на некоторых ноутбуках разработчиков он оставлял образы стыковочного устройстваasticsearch в странном состоянии (в основном те, кто использует OSx / mac для разработки)

действительно единственное, что помогло, это удалить изображения Elasticsearch и оттолкнуть их

Попробуйте стереть образ докера с помощью

docker-compose down --rmi local

предупреждение: это удалит все изображения, связанные с проектом, с вашего компьютера https://docs.docker.com/compose/reference/down/

затем повторно вытяните изображения

docker-compose pull
docker-compose up

и должно работать


, если это не поможет, попробуйте

$ docker images | grep elast

# elasticsearch                                                6.6.1               c6ffcb0ee97e        5 weeks ago         842MB
# elasticsearch                                                5.6                 34b57bbab755        2 months ago        486MB

docker rmi elasticsearch:6.6.1
docker rmi elasticsearch:5.6
...