'Creating docker container with tensorflow giving libssl.so error

I created a docker container with the Django app, celery, redis for database used Postgres. While we are importing tensorflow it is giving error of Libssl.so not found where as the file is exist in the docker container itself.

Python = 3.6.12

Tensorflow-gpu=1.12.0

cuda = 9.0

cudnn = 7

For docker build command is using: docker-compose build

and for running the container: docker compose up

The docker-compose.yml file which we are using are:

version: '3'

services:
  web:
    volumes:
      - static:/static
      - /usr/local/cuda/lib64/:/usr/local/cuda/lib64/
      - /usr/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/
      - /usr/lib/nvidia-410/:/usr/lib/nvidia-410/

    build:
      context: .
    ports:
      - "8000:8000"
    networks:
      - nginx_network
    hostname: "web"

  nginx:

    build: ./nginx
    volumes:
      - static:/static
    ports:
      - "3333:3333"
    networks:
      - nginx_network
    depends_on:
      - web
    hostname: "nginx"

  db:
     image: postgres:13.0-alpine
     container_name: ps01
     volumes:
       - postgres_data:/var/lib/postgresql/data/
     environment:
       - POSTGRES_USER=postgres
       - POSTGRES_PASSWORD=AVL^&*()
       - POSTGRES_DB=xtract_prod

networks:
  nginx_network:

volumes:
  static:

Docker File is:

FROM alpine:latest
FROM python:3.6.12
ENV LANG=C.UTF-8
RUN pip install --no-cache-dir --upgrade pip


#LC_ALL=C.UTF-8
# FROM python:3.5.2
# RUN apt-get install libssl1.1


# RUN export LD_LIBRARY_PATH=/home/xaltgpu/miniconda3/lib

RUN echo "/home/xaltgpu/miniconda3/lib" > /etc/ld.so.conf.d/openssl.conf
RUN ldconfig

RUN echo 'export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/lib/x86_64-linux-gnu:/usr/lib/nvidia-430' >> ~/.bashrc
#RUN nvidia-smi

RUN apt-get install libssl-dev libffi-dev -y


RUN apt-get update

RUN apt-get install libidn2-0
RUN apt-get install ffmpeg libsm6 libxext6  -y

COPY temp_1 /app/temp_1
COPY entrypoint.sh app/entrypoint.sh
COPY req.txt /app/req.txt
WORKDIR /app
RUN pip install -r req.txt
RUN ls
RUN pwd
COPY . /app

#FROM nvidia/cuda:9.0-base-ubuntu16.04

RUN chmod +x entrypoint.sh
ENTRYPOINT ["sh", "entrypoint.sh"]


NGINX Docker file

FROM nginx:1.19.0-alpine

COPY ./default.conf /etc/nginx/conf.d/default.conf

docker.conf

upstream django {
    server django_gunicorn:8000;
}

server {
    listen 80;

    location / {
        proxy_pass http://django;
    }

    location /static/ {
        alias /static/;
    }
}

Error i am getting while running entrypoint.sh python manage.py runserver

Error

Creating network "temp_nginx_network" with the default driver
Creating temp_web_1 ... done
Creating temp_nginx_1 ... done
Attaching to temp_web_1, temp_nginx_1
nginx_1  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
web_1    | Traceback (most recent call last):
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
web_1    |     self.execute(*args, **cmd_options)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 61, in execute
web_1    |     super().execute(*args, **options)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
web_1    |     output = self.handle(*args, **options)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 68, in handle
web_1    |     if not settings.DEBUG and not settings.ALLOWED_HOSTS:
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 82, in __getattr__
web_1    |     self._setup(name)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 69, in _setup
web_1    |     self._wrapped = Settings(settings_module)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 170, in __init__
web_1    |     mod = importlib.import_module(self.SETTINGS_MODULE)
web_1    |   File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
web_1    |     return _bootstrap._gcd_import(name[level:], package, level)
web_1    |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
web_1    |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
web_1    |   File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
web_1    |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
web_1    |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
web_1    |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
web_1    |   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
web_1    |   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
web_1    |   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
web_1    |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
web_1    |   File "/app/temp_1/xtract/__init__.py", line 5, in <module>
web_1    |     from .celery import app
web_1    |   File "/app/temp_1/xtract/celery.py", line 2, in <module>
web_1    |     from celery import Celery
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/local.py", line 509, in __getattr__
web_1    |     module = __import__(self._object_origins[name], None, None, [name])
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/app/__init__.py", line 5, in <module>
web_1    |     from celery import _state
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/_state.py", line 17, in <module>
web_1    |     from celery.utils.threads import LocalStack
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/utils/__init__.py", line 18, in <module>
web_1    |     from .log import LOG_LEVELS
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/utils/log.py", line 20, in <module>
web_1    |     from .term import colored
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/utils/term.py", line 13, in <module>
web_1    |     from celery.platforms import isatty
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/platforms.py", line 27, in <module>
web_1    |     from .exceptions import SecurityError
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/exceptions.py", line 59, in <module>
web_1    |     from kombu.exceptions import OperationalError
web_1    |   File "/usr/local/lib/python3.6/site-packages/kombu/exceptions.py", line 6, in <module>
web_1    |     from amqp import ChannelError, ConnectionError, ResourceError
web_1    |   File "/usr/local/lib/python3.6/site-packages/amqp/__init__.py", line 33, in <module>
web_1    |     from .connection import Connection  # noqa
web_1    |   File "/usr/local/lib/python3.6/site-packages/amqp/connection.py", line 21, in <module>
web_1    |     from .transport import Transport
web_1    |   File "/usr/local/lib/python3.6/site-packages/amqp/transport.py", line 9, in <module>
web_1    |     import ssl
web_1    |   File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
web_1    |     import _ssl             # if we can't import it, let the error propagate
web_1    | ImportError: libssl.so.1.1: cannot open shared object file: No such file or directory
web_1    | 
web_1    | During handling of the above exception, another exception occurred:
web_1    | 
web_1    | Traceback (most recent call last):
web_1    |   File "temp_1/manage.py", line 21, in <module>
web_1    |     main()
web_1    |   File "temp_1/manage.py", line 17, in main
web_1    |     execute_from_command_line(sys.argv)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
web_1    |     utility.execute()
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
web_1    |     self.fetch_command(subcommand).run_from_argv(self.argv)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 343, in run_from_argv
web_1    |     connections.close_all()
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 232, in close_all
web_1    |     for alias in self:
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 226, in __iter__
web_1    |     return iter(self.databases)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
web_1    |     res = instance.__dict__[self.name] = self.func(instance)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 153, in databases
web_1    |     self._databases = settings.DATABASES
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 82, in __getattr__
web_1    |     self._setup(name)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 69, in _setup
web_1    |     self._wrapped = Settings(settings_module)
web_1    |   File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 170, in __init__
web_1    |     mod = importlib.import_module(self.SETTINGS_MODULE)
web_1    |   File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
web_1    |     return _bootstrap._gcd_import(name[level:], package, level)
web_1    |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
web_1    |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
web_1    |   File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
web_1    |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
web_1    |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
web_1    |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
web_1    |   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
web_1    |   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
web_1    |   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
web_1    |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
web_1    |   File "/app/temp_1/xtract/__init__.py", line 5, in <module>
web_1    |     from .celery import app
web_1    |   File "/app/temp_1/xtract/celery.py", line 2, in <module>
web_1    |     from celery import Celery
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/local.py", line 509, in __getattr__
web_1    |     module = __import__(self._object_origins[name], None, None, [name])
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/app/__init__.py", line 5, in <module>
web_1    |     from celery import _state
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/_state.py", line 17, in <module>
web_1    |     from celery.utils.threads import LocalStack
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/utils/__init__.py", line 18, in <module>
web_1    |     from .log import LOG_LEVELS
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/utils/log.py", line 20, in <module>
web_1    |     from .term import colored
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/utils/term.py", line 13, in <module>
web_1    |     from celery.platforms import isatty
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/platforms.py", line 27, in <module>
web_1    |     from .exceptions import SecurityError
web_1    |   File "/usr/local/lib/python3.6/site-packages/celery/exceptions.py", line 59, in <module>
web_1    |     from kombu.exceptions import OperationalError
web_1    |   File "/usr/local/lib/python3.6/site-packages/kombu/exceptions.py", line 6, in <module>
web_1    |     from amqp import ChannelError, ConnectionError, ResourceError
web_1    |   File "/usr/local/lib/python3.6/site-packages/amqp/__init__.py", line 33, in <module>
web_1    |     from .connection import Connection  # noqa
web_1    |   File "/usr/local/lib/python3.6/site-packages/amqp/connection.py", line 21, in <module>
web_1    |     from .transport import Transport
web_1    |   File "/usr/local/lib/python3.6/site-packages/amqp/transport.py", line 9, in <module>
web_1    |     import ssl
web_1    |   File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
web_1    |     import _ssl             # if we can't import it, let the error propagate
web_1    | ImportError: libssl.so.1.1: cannot open shared object file: No such file or directory
nginx_1  | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
temp_web_1 exited with code 1
nginx_1  | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf differs from the packages version, exiting
nginx_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1  | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx_1  | 2022/05/05 11:30:27 [emerg] 1#1: host not found in upstream "django_gunicorn:8000" in /etc/nginx/conf.d/default.conf:2
nginx_1  | nginx: [emerg] host not found in upstream "django_gunicorn:8000" in /etc/nginx/conf.d/default.conf:2
temp_nginx_1 exited with code 1

Ignore Nginx error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source