Help OCSINVENTORY docker Ubuntu 20.04

Hi,

I’m student and for my exam, I must create a docker swarm and docker file.

One of my exercices, it’s to create a docker file with OCS Inventory.

I try, but I don’t understand where is my problem.

I need your help.

There is my docker-compose :

version: '3'

networks:
  localocs:

services:
  app:
    image: ocsinventory/ocsinventory-docker-image:2.9.2
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role==worker]
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
    environment:
      OCS_DB_SERVER: db
      OCS_DB_PORT: 3306
      OCS_DB_USER: ocs
      OCS_DB_PASS: ocs
      OCS_DB_NAME: ocsweb
      OCS_SSL_ENABLED: 0
      OCS_SSL_WEB_MODE: disabled
      OCS_SSL_COM_MODE: disabled
    volumes:
      - /mnt/filestore/data/ocs/app_data/apache/run:/var/run/httpd
      - /mnt/filestore/data/ocs/app_data/apache/run:/var/run/httpd.pid
      - /mnt/filestore/data/ocs/app_data/apache/lock:/var/lock/httpd
      - /mnt/filestore/data/ocs/app_data/apache/log:/var/log/httpd
      - /mnt/filestore/data/ocs/app_data/ocs/varlib:/var/lib/ocsinventory-reports/
      - /mnt/filestore/data/ocs/app_data/ocs/webconsole:/usr/share/ocsinventory-reports/ocsreports/
      - /mnt/filestore/data/ocs/app_data/ocs/perlext:/etc/ocsinventory-server/perl/
      - /mnt/filestore/data/ocs/app_data/ocs/pluginsext:/etc/ocsinventory-server/plugins/
    depends_on:
      - db
    ports:
      - 80:80
      - 443:443
    networks:
      - localocs

  db:
    image: mysql:8.0
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role==worker]
    environment:
      MYSQL_ROOT_PASSWORD: mdp
      MYSQL_USER: ocs
      MYSQL_PASSWORD: ocs
      MYSQL_DATABASE: ocsweb
    volumes:
        - /mnt/filestore/data/ocs/db_data:/docker-entrypoint-initdb.d/
        - /mnt/filestore/data/ocs/db_data:/var/lib/mysql
    ports:
      - 3306:3306
    networks:
      - localocs

  proxy:
    image: nginx
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role==worker]
    environment:
      PORT_ECOUTE: 80
      PORT_TYPE: ""
      SSL_CERT: ocs-dummy.crt
      SSL_KEY: ocs-dummy.key
      API_AUTH_FILE: ocsapi.htpasswd
      READ_TIMEOUT: 300
      CONNECT_TIMEOUT: 300
      SEND_TIMEOUT: 300
      MAX_BODY_SIZE: 1G
    volumes:
      - /mnt/filestore/data/ocs/proxy_data/templates:/etc/nginx/templates
      - /mnt/filestore/data/ocs/proxy_data/certs:/etc/nginx/certs
      - /mnt/filestore/data/ocs/proxy_data/auth:/etc/nginx/auth
    ports:
      - 8080:80
      - 4430:443
    depends_on:
      - app
    networks:
      - localocs

Can you help me to understand how to create this docker? Thanks a lot !

I reformated your post to use a code block </>for your compose file.

Your post needs further clearifications:

How do these two statements relate to the compose file (that creates 3 containers) you posted? And what is it exactly that you try to achive?

Thanks for your answer.

Here is the exercise I received:

  1. Set up a Swarm cluster (1 master, 3 slaves) with an external NFS storage space.
  2. Set up the following tools:
    has.
    A web interface allowing the basic display of the nodes and container of the cluster.
    b. A Nextcloud or Owncloud type document sharing system.
    c. GitLab-like DevOps platform.
    d. An OCSinventory-type IT asset inventory application.

The compose file I share with you, it’s the file i am working on. I read the documentation on the website OCS Inventory Docker image - OCS Inventory Documentation

But It doesn’t work and I don’t understand why. I hope someone can help me to understand the reasons.

Okay so your first “docker file” actualy ment the docker compose file. And when you refer to “how to create this docker” you man how to configure the container to be created.

Can you share the exact error message? It helps way better to understand your problem than “But it doesn’t work and I don’t understand why”.

Also, have you seen this link in the documentation that points to their git repository and indicates how to clone the repo and how to start the compose stack?

Logs of ocs application

ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | +----------------------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | |                                                          |
ocs_app.1.yjdbbgtcakdp@worker3    | |      Welcome to OCS Inventory NG Management Docker!      |
ocs_app.1.yjdbbgtcakdp@worker3    | |                                                          |
ocs_app.1.yjdbbgtcakdp@worker3    | +----------------------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | +----------------------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | |   Setting Apache Server Name to 'localhost'
ocs_app.1.yjdbbgtcakdp@worker3    | +----------------------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | +-----------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | |   Customizing from environment variables...   |
ocs_app.1.yjdbbgtcakdp@worker3    | +-----------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | Applying Config OCS_DB_USER=ocs from environment variable
ocs_app.1.yjdbbgtcakdp@worker3    | Applying Config OCS_DB_NAME=ocsweb from environment variable
ocs_app.1.yjdbbgtcakdp@worker3    | Applying Config OCS_DB_PORT=3306 from environment variable
ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | +--------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | |   Removing not used files...   |
ocs_app.1.yjdbbgtcakdp@worker3    | +--------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | Enabling conf ocsinventory-reports.
ocs_app.1.yjdbbgtcakdp@worker3    | To activate the new configuration, you need to run:
ocs_app.1.yjdbbgtcakdp@worker3    |   service apache2 reload
ocs_app.1.yjdbbgtcakdp@worker3    | Enabling conf z-ocsinventory-server.
ocs_app.1.yjdbbgtcakdp@worker3    | To activate the new configuration, you need to run:
ocs_app.1.yjdbbgtcakdp@worker3    |   service apache2 reload
ocs_app.1.yjdbbgtcakdp@worker3    | Enabling conf zz-ocsinventory-restapi.
ocs_app.1.yjdbbgtcakdp@worker3    | To activate the new configuration, you need to run:
ocs_app.1.yjdbbgtcakdp@worker3    |   service apache2 reload
ocs_app.1.yjdbbgtcakdp@worker3    | +----------------------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | |                 OK, prepare finshed ;-)                  |
ocs_app.1.yjdbbgtcakdp@worker3    | |                                                          |
ocs_app.1.yjdbbgtcakdp@worker3    | |      Starting OCS Inventory NG Management Docker...      |
ocs_app.1.yjdbbgtcakdp@worker3    | +----------------------------------------------------------+
ocs_app.1.yjdbbgtcakdp@worker3    | 
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun  9 19:44:37 2022] OCSINVENTORY: (SOAP): Cannot find XML::Entities
ocs_app.1.yjdbbgtcakdp@worker3    | ocsinventory-server: Can't load SOAP::Transport::HTTP* - Web service will be unavailable
ocs_app.1.yjdbbgtcakdp@worker3    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.2.6. Set the 'ServerName' directive globally to suppress this message
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun  9 19:44:39 2022] OCSINVENTORY: (SOAP): Cannot find XML::Entities
ocs_app.1.yjdbbgtcakdp@worker3    | ocsinventory-server: Can't load SOAP::Transport::HTTP* - Web service will be unavailable
ocs_app.1.yjdbbgtcakdp@worker3    | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.2.6. Set the 'ServerName' directive globally to suppress this message
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:44:47.675246 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.41 (Ubuntu) mod_perl/2.0.11 Perl/v5.30.0 configured -- resuming normal operations
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:44:47.675609 2022] [core:notice] [pid 1] AH00094: Command line: '/usr/sbin/apache2 -D FOREGROUND'
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:04 +0200] "GET /ocsreports/ HTTP/1.1" 200 1090 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:00 +0200] "GET /ocsreports/ HTTP/1.1" 200 1090 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/libraries/bootstrap/css/bootstrap.min.css HTTP/1.1" 200 20113 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/libraries/select2/css/select2.min.css HTTP/1.1" 200 2354 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/libraries/bootstrap/css/bootstrap-theme.min.css HTTP/1.1" 200 3143 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/bootstrap-datetimepicker.css HTTP/1.1" 200 2042 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/libraries/datatable/media/css/dataTables.bootstrap.css HTTP/1.1" 200 1696 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/bootstrap-formhelpers.css HTTP/1.1" 200 5321 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/themes/OCS/style.css HTTP/1.1" 200 3346 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/computer_details.css HTTP/1.1" 200 1179 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/header.css HTTP/1.1" 200 1216 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/dataTables-custom.css HTTP/1.1" 200 1579 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/forms.css HTTP/1.1" 200 1651 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/css/ocsreports.css HTTP/1.1" 200 3107 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:45:05 +0200] "GET /ocsreports/favicon.ico HTTP/1.1" 200 370403 "http://192.168.1.62/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:06.789787 2022] [php7:warn] [pid 84] [client 10.0.0.2:63182] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:06.791011 2022] [php7:warn] [pid 84] [client 10.0.0.2:63182] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:06.806454 2022] [php7:warn] [pid 84] [client 10.0.0.2:63182] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:06.807048 2022] [php7:warn] [pid 84] [client 10.0.0.2:63182] PHP Warning:  require(install.php): failed to open stream: No such file or directory in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:06.807312 2022] [php7:error] [pid 84] [client 10.0.0.2:63182] PHP Fatal error:  require(): Failed opening required 'install.php' (include_path='.:/usr/share/php') in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:46:06 +0200] "GET /ocsreports/ HTTP/1.1" 500 324 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:09.811374 2022] [php7:warn] [pid 89] [client 10.0.0.2:63183] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:09.813989 2022] [php7:warn] [pid 89] [client 10.0.0.2:63183] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:09.814175 2022] [php7:warn] [pid 89] [client 10.0.0.2:63183] PHP Warning:  require(install.php): failed to open stream: No such file or directory in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:09.814273 2022] [php7:error] [pid 89] [client 10.0.0.2:63183] PHP Fatal error:  require(): Failed opening required 'install.php' (include_path='.:/usr/share/php') in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:46:09 +0200] "GET /ocsreports/ HTTP/1.1" 500 324 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:12.469060 2022] [php7:warn] [pid 87] [client 10.0.0.2:63190] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:12.470870 2022] [php7:warn] [pid 87] [client 10.0.0.2:63190] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:12.471260 2022] [php7:warn] [pid 87] [client 10.0.0.2:63190] PHP Warning:  require(install.php): failed to open stream: No such file or directory in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:12.471448 2022] [php7:error] [pid 87] [client 10.0.0.2:63190] PHP Fatal error:  require(): Failed opening required 'install.php' (include_path='.:/usr/share/php') in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:46:12 +0200] "GET /ocsreports/ HTTP/1.1" 500 324 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:43.445990 2022] [php7:warn] [pid 86] [client 10.0.0.2:63213] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:43.448708 2022] [php7:warn] [pid 86] [client 10.0.0.2:63213] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:43.449479 2022] [php7:warn] [pid 86] [client 10.0.0.2:63213] PHP Warning:  require(install.php): failed to open stream: No such file or directory in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:43.449892 2022] [php7:error] [pid 86] [client 10.0.0.2:63213] PHP Fatal error:  require(): Failed opening required 'install.php' (include_path='.:/usr/share/php') in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:46:43 +0200] "GET /ocsreports/ HTTP/1.1" 500 324 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:45.409009 2022] [php7:warn] [pid 85] [client 10.0.0.2:63214] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:45.411644 2022] [php7:warn] [pid 85] [client 10.0.0.2:63214] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:45.412112 2022] [php7:warn] [pid 85] [client 10.0.0.2:63214] PHP Warning:  require(install.php): failed to open stream: No such file or directory in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:45.412149 2022] [php7:error] [pid 85] [client 10.0.0.2:63214] PHP Fatal error:  require(): Failed opening required 'install.php' (include_path='.:/usr/share/php') in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:46:45 +0200] "GET /ocsreports/ HTTP/1.1" 500 324 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:47.215465 2022] [php7:warn] [pid 89] [client 10.0.0.2:63219] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:47.216808 2022] [php7:warn] [pid 89] [client 10.0.0.2:63219] PHP Warning:  mysqli_fetch_object() expects parameter 1 to be mysqli_result, bool given in /usr/share/ocsinventory-reports/ocsreports/require/function_commun.php on line 38
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:47.217211 2022] [php7:warn] [pid 89] [client 10.0.0.2:63219] PHP Warning:  require(install.php): failed to open stream: No such file or directory in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | [Thu Jun 09 19:46:47.217260 2022] [php7:error] [pid 89] [client 10.0.0.2:63219] PHP Fatal error:  require(): Failed opening required 'install.php' (include_path='.:/usr/share/php') in /usr/share/ocsinventory-reports/ocsreports/require/header.php on line 168
ocs_app.1.yjdbbgtcakdp@worker3    | 10.0.0.2 - - [09/Jun/2022:19:46:47 +0200] "GET /ocsreports/ HTTP/1.1" 500 324 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"

logs of ocs db

ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09 17:44:18+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1debian10 started.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09 17:44:31+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09 17:44:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1debian10 started.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:44:47.881036Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 1
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:44:50.300895Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:45:22.868972Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:45:28.953511Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:45:28.955152Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:45:28.990333Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:45:29.899549Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
ocs_db.1.mae4r6knqm1j@worker1    | 2022-06-09T17:45:29.900214Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock

logs of ocs proxy

ocs_proxy.1.kdb31eegeou0@worker2    | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
ocs_proxy.1.kdb31eegeou0@worker2    | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
ocs_proxy.1.kdb31eegeou0@worker2    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
ocs_proxy.1.kdb31eegeou0@worker2    | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
ocs_proxy.1.kdb31eegeou0@worker2    | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
ocs_proxy.1.kdb31eegeou0@worker2    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
ocs_proxy.1.kdb31eegeou0@worker2    | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
ocs_proxy.1.kdb31eegeou0@worker2    | /docker-entrypoint.sh: Configuration complete; ready for start up
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: using the "epoll" event method
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: nginx/1.21.6
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: OS: Linux 5.4.0-117-generic
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: start worker processes
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: start worker process 33
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:44:43 [notice] 1#1: start worker process 34
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:47:09 [error] 33#33: *1 "/usr/share/nginx/html/ocsreports/index.html" is not found (2: No such file or directory), client: 10.0.0.2, server: localhost, request: "GET /ocsreports/ HTTP/1.1", host: "192.168.1.62:8090"
ocs_proxy.1.kdb31eegeou0@worker2    | 10.0.0.2 - - [09/Jun/2022:17:47:09 +0000] "GET /ocsreports/ HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36" "-"
ocs_proxy.1.kdb31eegeou0@worker2    | 2022/06/09 17:47:10 [error] 33#33: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 10.0.0.2, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.1.62:8090", referrer: "http://192.168.1.62:8090/ocsreports/"
ocs_proxy.1.kdb31eegeou0@worker2    | 10.0.0.2 - - [09/Jun/2022:17:47:10 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://192.168.1.62:8090/ocsreports/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36" "-"

And when I go on the website in 192.168.1.62/ocsreports, I have a error message HTTP ERROR 500 or sometime mysql db connection refused.

I compared your compose file with the one from OCSInventory-Docker-Image/docker-compose.yml at master · OCSInventory-NG/OCSInventory-Docker-Image · GitHub.

What immediatly hits the eye:

  • It looks like you migrated the compose file from the OCS git repo to support swarm stack deployments
  • you use bind mounts instead of volumes
    • which is generaly a terrible idea for swarm deployment, as swarm tasks (which then create the container) can be deployed on any node that satisfies the placement constraint.
    • With swarm stacks this might work when only a single node statisfies the placement contraints, but with more than one it will definitly not work as a local folder is local to the node - this is where nfs commes into the picture.
  • You create way more volume mappins than the original example uses:

Can you let me understand what made the additional volumes necessary? Personaly I wouldn’t have mapped the /var/run/…, /var/lock and /var/log without a specific reason.

The combination of not using named volumes and using volume mappings for wrong folders inside the container can already be the reason for the problems you experience!

I would higly suggest to setup an nfs v4 server, create the nfs exports, mount the nfs share on your host, create folders for the volumes in your nfs share and then declare the named volumes baked by the nfs share in your compose file .

Also please begin with only using those volumes that the original example uses. You can always add more volumes later.

creating an nfs baked volume can look like this

volumes:
  ocsreportsdata:
    driver_opts:
      type: nfs 
      o: addr=192.168.x.x,nfsvers=4
      device: :/export/ocs/reportdata

Notes:

  • nfs v4 is more reliable than nfs v3
  • the path declared in device: MUST exist on the nfs share
  • make sure the owner UID/GID of the folder you delcared as device matches the UID/GID of the process in the container (depending on the image it might take care of this itself or don’t)
  • named volumes are created immutable → wheneve you change its configuration it must be manualy deleted so docker stack deploy can create a new named-volume using the new parameters - the data on the nfs share will not be affected by the deletion
  • named volumes are “local” to a node. It will be created the first time a container using it will be scheduled on the node. Bare in mind that if you want to change the volume declaration, you might have to delete it on each node to let docker recreate it

Thanks for your response.

I have a NFS. It’s /mnt/filestore.

I look many docker-compose for OCS and the volumes was different for each files. So I try many combination with volumes.

I copy paste the official docker-compose and I change the volume with my NFS volumes and it doesn’t work too.

I will try again and again until find the answer :smiley: Thanks for your help.

Please try do not report back like this, instead share your updated docker-compose file and share errors output from the logs.

Please try without volumes first and then add volume by volume. But please keep in mind that the configuration of a defined volume itself in the compose file will not be reflected on the volume once its created - it needs to be deleted (docker volume rm) and re-created (swarm deployments to this automaticly) to reflect the config changes.

Btrw. your nginx logs indicate that you didn’t update the configuration you mount inside the container - since you changes the service names, you will need to update the reverse proxy configuration as well!

1 Like