1

I'm building a script to automate Instagram marketing and are using the instagrapi library. This script (login.py) logs in:

from instagrapi import Client
cl = Client()
cl.login(username,password)

It works fine when running it locally (fill in your own username and password). However, once I run it in a docker container, it gives me a Segmentation fault. Any idea why this happens?

Dockerfile:

FROM python:3.8-slim-buster
RUN python -m pip install instagrapi
RUN python -m pip install Pillow
RUN mkdir /build_zone
ADD . /build_zone
WORKDIR /build_zone
ENTRYPOINT ["tail", "-f", "/dev/null"]

To reproduce the error, add Dockerfile and login.py to a folder, open terminal and navigate to the folder, build the image via docker build -t instagram:v1.0 . and run it via docker run instagram:v1.0. Then open another terminal, find the container id (docker ps -a) and enter the container docker exec -it 'containerid' bash. Then run python login.py in the container.

I read somewhere that this error may be due to some underlying C code. Could it be that the Dockerfile is missing some dependencies?

Local env: python3.8, Mac M1 pro

aleksandereiken
  • 430
  • 5
  • 9
  • 1
    It works just fine when I use python3:8 instead of python3:8-slim-buster. So it's clear that this image is missing something that you need. – Frank Yellin Feb 07 '22 at 21:02
  • Ahh yes! Thanks alot! Don't know why I didn't think of that, but it works. Amazing, thanks!! – aleksandereiken Feb 07 '22 at 21:15
  • (Why the roundabout way to run the application? Why not set the image's `CMD python login.py`?) – David Maze Feb 07 '22 at 21:36
  • It was only for debugging purposes, as the 'Segmentation fault' error was not printet to the terminal when running the container as you describe above, so I had to keep the container running and enter it to find out what was going on. But now that the issue is solved, then your way of running the container is of course the preferred. – aleksandereiken Feb 07 '22 at 21:59
  • For debugging purpose your can simply `docker run -it --rm instagram:v1.0 bash` and run your commands there rather that through an other terminal – Zeitounator Feb 07 '22 at 22:11

0 Answers0