jokob-sk / NetAlertX

🖧🔍 WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
GNU General Public License v3.0
2.66k stars 153 forks source link

Error executing Docker commands. #765

Closed meetgyn closed 1 week ago

meetgyn commented 3 weeks ago

Is there an existing issue for this?

Current Behavior

Error executing Docker commands. I am trying to use it in Docker, but without success. It is not working at all, and I need your help if possible. I am using Ubuntu 24.04. image

Expected Behavior

Docker commands are not working.

Steps To Reproduce

git clone /opt/projetos/NetAlertX/ cd NetAlertX docker-compose up -d

app.conf

The app.config and db were not created. The folders remain empty.

docker-compose.yml

docker-compose up -d :
root@greenbone:/opt/projetos/NetAlertX/NetAlertX-24.7.18# docker-compose up -d
WARNING: The ALWAYS_FRESH_INSTALL variable is not set. Defaulting to a blank string.
Building netalertx
[+] Building 13.0s (7/14)                                                                                                                                     docker:default
 => [internal] load build definition from Dockerfile                                                                                                                    0.0s
 => => transferring dockerfile: 2.19kB                                                                                                                                  0.0s
 => WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1)                                                                                          0.0s
 => WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 24)                                                                                         0.0s
 => [internal] load metadata for docker.io/library/alpine:3.20                                                                                                          1.2s
 => [internal] load .dockerignore                                                                                                                                       0.0s
 => => transferring context: 285B                                                                                                                                       0.0s
 => ERROR importing cache manifest from docker.io/jokob-sk/netalertx:buildcache                                                                                         1.0s
 => [internal] load build context                                                                                                                                       0.6s
 => => transferring context: 732.26kB                                                                                                                                   0.6s
 => CACHED [builder 1/4] FROM docker.io/library/alpine:3.20@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5                                     0.0s
 => ERROR [builder 2/4] RUN apk add --no-cache bash python3 python3-dev gcc musl-dev libffi-dev openssl-dev     && python -m venv /opt/venv                            10.7s
------                                                                                                                                                                       
 > importing cache manifest from docker.io/jokob-sk/netalertx:buildcache:    
 > [builder 2/4] RUN apk add --no-cache bash python3 python3-dev gcc musl-dev libffi-dev openssl-dev     && python -m venv /opt/venv:                                        
0.603 fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz                                                                                          
5.605 fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
5.605 WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.20/main: temporary error (try again later)
10.61 WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.20/community: temporary error (try again later)
10.61 ERROR: unable to select packages:
10.61   bash (no such package):
10.61     required by: world[bash]
10.61   gcc (no such package):
10.61     required by: world[gcc]
10.61   libffi-dev (no such package):
10.61     required by: world[libffi-dev]
10.61   musl-dev (no such package):
10.61     required by: world[musl-dev]
10.61   openssl-dev (no such package):
10.61     required by: world[openssl-dev]
10.61   python3 (no such package):
10.61     required by: world[python3]
10.61   python3-dev (no such package):
10.61     required by: world[python3-dev]
------

 3 warnings found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1)
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 24)
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 5)
Dockerfile:8
--------------------
   7 |     # Install build dependencies
   8 | >>> RUN apk add --no-cache bash python3 python3-dev gcc musl-dev libffi-dev openssl-dev \
   9 | >>>     && python -m venv /opt/venv
  10 |         
--------------------
ERROR: failed to solve: process "/bin/sh -c apk add --no-cache bash python3 python3-dev gcc musl-dev libffi-dev openssl-dev     && python -m venv /opt/venv" did not complete successfully: exit code: 7
ERROR: Service 'netalertx' failed to build : Build failed

What branch are you running?

Dev

app.log

no create

Debug enabled

jokob-sk commented 3 weeks ago

Hi @meetgyn ,

You need to make sure you use existing locations where the DB and Config are stored:

image

You don't need to clone the repo (unless you want to help develop / submit a PR - which is super welcome). If you want to set up NetAlertX for development, check this guide: https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEV_ENV_SETUP.md

If you only want to run the application, you only need 3 folders:

  1. One folder with the docker-compose.yml file let's say netalertx_compose
  2. One folder with the config, let's say netalertx_config
  3. One folder for the DB, let's say netalertx_db

In the netalertx_compose folder, create a file called docker-compose.yml, with the following content:

version: "3"
services:
  netalertx:
    container_name: netalertx
    # use the below line if you want to test the latest dev image
    # image: "jokobsk/netalertx-dev:latest" 
    image: "jokobsk/netalertx:latest"      
    network_mode: "host"        
    restart: unless-stopped
    volumes:
      - netalertx_config:/app/config
      - netalertx_db:/app/db      
      # (optional) useful for debugging if you have issues setting up the container
      #- local/path/logs:/app/front/log
    environment:
      - TZ=Europe/Berlin      
      - PORT=20211

you might need to change the following 2 lines so it's an absolute path, depending where these 2 folders are located:

      - netalertx_config:/app/config
      - netalertx_db:/app/db   

then cd into the netalertx_compose folder and run docker-compose up -d.

Hope this helps, j

meetgyn commented 3 weeks ago

Thank you very much for your help. I am setting up the scenario you explained to me. When I ran the docker-compose, it already returned some errors that I'm trying to understand

=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1) 0.0s => WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 24)

=> ERROR importing cache manifest from docker.io/jokob-sk/netalertx:buildcache 3.7s => ERROR [runner 6/6] RUN /app/dockerfiles/pre-setup.sh 0.4s


importing cache manifest from docker.io/jokob-sk/netalertx:buildcache:



[runner 6/6] RUN /app/dockerfiles/pre-setup.sh: 0.380 /bin/sh: /app/dockerfiles/pre-setup.sh: not found

3 warnings found (use docker --debug to expand):

jokob-sk commented 3 weeks ago

Hi,

You need to use a custom .env file with your environment variables. Do you have one? Can you post the content of it?

Also, are you trying to build the app from scratch for development? Or are you only trying to run the application?

Here is an example command I use to build the container:

sudo docker-compose --env-file ../.env up -d

My folder structure is:

- NetAlertX 
  -  back
  - config
  - ...
- .env

I cd ./NetAlertX and run the sudo docker-compose --env-file ../.env up -d command in the folder, so it picks up the custom, environment file located in the parent directory. My .env file looks something like this:

APP_DATA_LOCATION=/volume1/docker_appdata
DEV_LOCATION=/volume1/NetAlertX
TZ=Europe/Berlin
PORT=20211
jokob-sk commented 1 week ago

no activity for ~2 weeks -> closing