Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running container image failed #1074

Closed
fliepflapfloep opened this issue Sep 21, 2020 · 6 comments · Fixed by #1106
Closed

Running container image failed #1074

fliepflapfloep opened this issue Sep 21, 2020 · 6 comments · Fixed by #1106
Labels

Comments

@fliepflapfloep
Copy link

Using a clean VM running Ubuntu 20.04.1 to run a Spiderfoot container. I have placed the user in the docker group to avoid having to use "sudo" with every command.
The latest version of Spiderfoot has been used by using the following command: "git clone https://github.com/smicallef/spiderfoot.git" and the image has been build using: "docker build -t spiderfoot . "

When i try to start a container using the image i just created i get the following error message:

~$ docker run -p 5009:5001 spiderfoot
Traceback (most recent call last):
  File "sf.py", line 46, in <module>
    backupCount=30
  File "/usr/lib/python3.6/logging/handlers.py", line 202, in __init__
    BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
  File "/usr/lib/python3.6/logging/handlers.py", line 57, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python3.6/logging/__init__.py", line 1032, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.6/logging/__init__.py", line 1061, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/home/spiderfoot/log/spiderfoot.debug.log'

What can be the cause of the problem?

@smicallef smicallef added the bug label Sep 22, 2020
@maandagdev
Copy link

I am also having the same issue, when going to an older release everything works properly.

@sibtcha
Copy link

sibtcha commented Oct 6, 2020

I'm also having the same issue 😞

@bcoles
Copy link
Contributor

bcoles commented Oct 6, 2020

It is caused by a permission issue due to the log directory.

Here's a work around.

  1. Delete or rename the log directory: mv log logs.old
  • (if you've only ever been using SpiderFoot in the docker container, and not on the host, then this directory should be empty)
  1. Apply the following diff.
diff --git a/Dockerfile b/Dockerfile
index 0dcda94c..3ef6f748 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -49,6 +49,8 @@ WORKDIR /home/spiderfoot
 # Place database and configs outside installation directory
 ENV SPIDERFOOT_DATA /var/lib/spiderfoot
 
+ENV SPIDERFOOT_LOGS /home/spiderfoot/log
+
 # Run everything as one command so that only one layer is created
 RUN apk --update --no-cache add python3 musl openssl libxslt tinyxml libxml2 jpeg zlib openjpeg \
     && addgroup spiderfoot \
@@ -58,6 +60,8 @@ RUN apk --update --no-cache add python3 musl openssl libxslt tinyxml libxml2 jpe
     && rm -rf /lib/apk/db \
     && rm -rf /root/.cache \
     && mkdir $SPIDERFOOT_DATA \
+    && mkdir $SPIDERFOOT_LOGS \
+    && chown spiderfoot:spiderfoot $SPIDERFOOT_LOGS \
     && chown spiderfoot:spiderfoot $SPIDERFOOT_DATA
 
 COPY --from=build /opt/venv /opt/venv
  1. Build the image: docker build -t spiderfoot .
  2. You can now run SpiderFoot: docker run -p 5001:5001 spiderfoot

@sibtcha
Copy link

sibtcha commented Oct 6, 2020

Perfect, it work now. Thank you

@TheTechromancer
Copy link
Contributor

The above fix didn't work on my system, because the final line COPY . . was overwriting the permissions.

Moving COPY . . before the chown commands fixed the issue for me.

@bcoles
Copy link
Contributor

bcoles commented Jun 13, 2021

The above fix didn't work on my system, because the final line COPY . . was overwriting the permissions.

Moving COPY . . before the chown commands fixed the issue for me.

Strange. The above fix should have worked for you. COPY . . should not overwrite the permissions on log if the log directory does not exist. Are you sure you removed the log directory first?

I've fixed this in #1182 by adding the log directory to .dockerignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants