thirdgen88 / ignition-docker

Ignition Docker Community Image
MIT License
72 stars 17 forks source link

host volume path #127

Closed kreddad closed 1 year ago

kreddad commented 1 year ago

Im having hard time to set host path getting the error below I did follow the instruction on kcollins/ignition docker (using Unraid for host machine ) my settings: my path : /mnt/user/appdata/ignition/data:/var/lib/ignition/data ports: 8088:8088 that is the only sting I'm using thank you

/usr/local/bin/docker-entrypoint.sh: line 412: /usr/local/share/ignition/data/ignition.conf: No such file or directory FATAL | wrapper | Unable to open configuration file: data/ignition.conf (No such file or directory) FATAL | wrapper | Current working directory: /usr/local/share/ignition FATAL | wrapper | The Wrapper will stop. init | WARNING: Gateway is not initialized and no password option is specified init | Disabling automated gateway commissioning, manual input will be required init | Adjusting ownership of 1 Ignition installation files... init | Staging user step-down from 'root' init | Starting ![path](https://user-images.githubusercontent.com/31426322/214478331-63a75a3a-2a45-43e0-9e52-ce72f6ea8ce2.PNG) ![path](https://user-images.githubusercontent.com/31426322/214478386-101bb891-b959-440b-854d-f4f047e05b9e.PNG) Ignition Gateway...

thirdgen88 commented 1 year ago

It looks like you're wanting to use the alternate method in this image for persisting your data. Try setting the container path for your bind-mount to /data instead of /var/lib/ignition/data.

kreddad commented 1 year ago

thanks for replaying did chnge the path to [/mnt/user/appdata/ignition:/data] but I'm getting different error settings: image : kcollins/ignition port: 8088:8088 path: mnt/user/appdata/ignition:/data

init     | New Volume detected at /data, copying existing image files prior to Gateway Launch...
init     | WARNING: Gateway is not initialized and no password option is specified 
init     |   Disabling automated gateway commissioning, manual input will be required
init     | Adjusting ownership of 5 Ignition installation files...
init     | Staging user step-down from 'root'
init     | Starting Ignition Gateway...
wrapper  | 2023/01/25 16:23:01 | --> Wrapper Started as Console
wrapper  | 2023/01/25 16:23:01 | Java Service Wrapper Standard Edition 64-bit 3.5.42
wrapper  | 2023/01/25 16:23:01 |   Copyright (C) 1999-2020 Tanuki Software, Ltd. All Rights Reserved.
wrapper  | 2023/01/25 16:23:01 |     http://wrapper.tanukisoftware.com
wrapper  | 2023/01/25 16:23:01 |   Licensed to Inductive Automation for Inductive Automation
wrapper  | 2023/01/25 16:23:01 | 
wrapper  | 2023/01/25 16:23:02 | Launching a JVM...
jvm 1    | 2023/01/25 16:23:02 | WrapperManager: Initializing...
jvm 1    | 2023/01/25 16:23:07 | **E [IgnitionGateway               ]: Error initializing web manager:**  
jvm 1    | 2023/01/25 16:23:07 | java.lang.IllegalStateException: Could not create data//gateway.xml from data//gateway.xml_clean.
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.catapult.util.FileUtil.ensureFileExists(FileUtil.java:104)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.ignition.gateway.web.WebResourceManagerImpl.readGatewayProperties(WebResourceManagerImpl.java:465)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.ignition.gateway.web.WebResourceManagerImpl.<init>(WebResourceManagerImpl.java:115)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.ignition.gateway.IgnitionGateway.<init>(IgnitionGateway.java:524)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.ignition.gateway.IgnitionGateway.main(IgnitionGateway.java:299)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.catapult.Catapult.main(Catapult.java:8)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:349)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.lang.Thread.run(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 | **E [IgnitionGateway               ]: Error starting the GCU Request Server**:  
jvm 1    | 2023/01/25 16:23:07 | java.io.FileNotFoundException: data/response (Permission denied)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.io.RandomAccessFile.open0(Native Method)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.io.RandomAccessFile.open(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.io.RandomAccessFile.<init>(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.io.RandomAccessFile.<init>(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.io.RandomAccessFile.<init>(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.catapult.GcuRequestServer.<init>(GcuRequestServer.java:37)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.ignition.gateway.IgnitionGateway.<init>(IgnitionGateway.java:532)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.ignition.gateway.IgnitionGateway.main(IgnitionGateway.java:299)
jvm 1    | 2023/01/25 16:23:07 |        at com.inductiveautomation.catapult.Catapult.main(Catapult.java:8)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
jvm 1    | 2023/01/25 16:23:07 |        at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:349)
jvm 1    | 2023/01/25 16:23:07 |        at java.base/java.lang.Thread.run(Unknown Source)
wrapper  | 2023/01/25 16:23:09 | <-- Wrapper Stopped
thirdgen88 commented 1 year ago

At this point, it looks like you're running into permission issues on the Ignition data volume (mounted at /data). The entrypoint will attempt to adjust the file ownership on this path during startup as root, but depending on the specifics of that mount, it may or may not work as intended. You'll probably want to discover and then align the UID/GID of that mounted path (and the permissions set on it on the Unraid side) with your Ignition container (via IGNITION_UID and IGNITION_GID environment variables).

thirdgen88 commented 1 year ago

Alternatively, you could try also setting IGNITION_UID=0 and IGNITION_GID=0 to try running the container as root. That may or may not work (and may or may not align with your intent), but I thought I'd mention it as something you could try. Ultimately, it is all going to come down to the behavior of that persisted path in your container (from the Unraid side).

kreddad commented 1 year ago

Did work with using IGNITION_UID=0 and IGNITION_GID=0 Thank you so much

marioqqq commented 10 months ago

Hi, I had a similar issue as @kreddad and your solution worked, but now I'm not able to mount projects locally for backup. Any tips how to solve it? Thx

thirdgen88 commented 10 months ago

Can you provide more details of your configuration and/or any errors you're observing?

marioqqq commented 10 months ago

Sure, I'm using Raspberry Pi 4B 8GB with latest 64 bit Raspbian OS Lite.

My docker-compose.yaml:

services:
  gateway:
    container_name: ignition
    image: inductiveautomation/ignition:latest
    ports:
      - 9088:8088
      - 9043:8043
    volumes:
      - ./data:/usr/local/bin/ignition/data
    environment:
      - IGNITION_UID=0
      - IGNITION_GID=0
      - ACCEPT_IGNITION_EULA=Y
      - GATEWAY_ADMIN_USERNAME=admin
      - GATEWAY_ADMIN_PASSWORD=password
      - IGNITION_EDITION=maker
      - TZ=Europe/Bratislava
    command:
     - wrapper.java.maxmemory=2048
    network_mode: bridge
    restart: unless-stopped

And i got this:

init     | 2023/12/23 11:58:32 | WARNING: IGNITION_UID='0' and IGNITION_GID='0' are ignored when not running as root (uid=0), detected uid=2003
init     | 2023/12/23 11:58:32 | Creating init.properties file
init     | 2023/12/23 11:58:32 | Creating gateway.xml
cp: cannot stat '/usr/local/bin/ignition/data/gateway.xml_clean': No such file or directory

But when I don't use any volumes, everything works just fine.

thirdgen88 commented 10 months ago

    # ...
    image: inductiveautomation/ignition:latest

The difference here is that you're using inductiveautomation/ignition image. The official image has some similarities to this "unofficial" image I maintain, but there are many differences as well. One of those differences is that inductiveautomation/ignition defaults to non-root ignition user (with UID/GID 2003), whereas kcollins/ignition defaults to root but steps down to ignition (with UID/GID 999). That is why you're also getting this warning:

init     | 2023/12/23 11:58:32 | WARNING: IGNITION_UID='0' and IGNITION_GID='0' are ignored when not running as root (uid=0), detected uid=2003

You'd need to add user: 0:0 as well if you're using the official image. However, that won't solve your bind-mount issue that you're running into. Watch the section of this ICC2022 presentation starting at time index 9:02 for information on persisting gateway state: https://inductiveautomation.com/resources/icc/2022/running-ignition-in-a-container-environment.

Here is the linked gist with some of the examples as well: https://gist.github.com/thirdgen88/c6439d82b5ea720d62ab0a7e00e7b1a1

If you're on Raspberry Pi, you'll likely want to align the UID/GID of your pi user (or whatever user you're using there, inspect with id command) with the IGNITION_UID and IGNITION_GID env vars, and then use user: 0:0 in your service spec. All of this goes away if you just use a named volume instead (do you really need a bind-mount?).

Hope this helps!

Kevin C.

marioqqq commented 10 months ago

I see. I tried something wit friend and made it work. You should use chmod +777 for ./data dir. Also you can't bind directly to /usr/.../data, but /usr/.../data/projects etc. So IGNITION_UID and IGNITION_GID are not needed.

Anyway, thx for help 🙂

thirdgen88 commented 10 months ago

Sounds good.. What you use varies a lot based on what you need! Glad you're up and running!