I have an image segmentation_site_segmentation_site
. The image is built from the following Dockerfile and Docker-Compose file.
junaidali@ubuntu:~/Documents/segmentation/segmentation_site$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
segmentation_site_segmentation_site latest e1793ab30737 3 hours ago 3.07GB
Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
WORKDIR /app
ADD . /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . /app
Docker-compose file
version: '3'
services:
segmentation_site:
build: .
command: gunicorn -b 0.0.0.0:8000 segmentation_site.wsgi
ports:
- 8000:8000
Doing docker-compose up
runs the image perfectly, as the model loaded shows up.
junaidali@ubuntu:~/Documents/segmentation/segmentation_site$ sudo docker-compose up
Starting segmentation_site_segmentation_site_1 ... done
Attaching to segmentation_site_segmentation_site_1
segmentation_site_1 | [2022-05-10 16:36:26 +0000] [1] [INFO] Starting gunicorn 20.0.4
segmentation_site_1 | [2022-05-10 16:36:26 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
segmentation_site_1 | [2022-05-10 16:36:26 +0000] [1] [INFO] Using worker: sync
segmentation_site_1 | [2022-05-10 16:36:26 +0000] [8] [INFO] Booting worker with pid: 8
segmentation_site_1 | 2022-05-10 16:36:32.195915: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
segmentation_site_1 | 2022-05-10 16:36:32.196645: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
segmentation_site_1 | tensorflow imported.
segmentation_site_1 | 2022-05-10 16:36:46.315257: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
segmentation_site_1 | 2022-05-10 16:36:46.317221: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
segmentation_site_1 | 2022-05-10 16:36:46.318149: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (73c56bba055c): /proc/driver/nvidia/version does not exist
segmentation_site_1 | model loaded.
But when I am running this image as container using docker run e1793ab30737
it shows no output
junaidali@ubuntu:~/Documents/segmentation/segmentation_site$ sudo docker run e1793ab30737
junaidali@ubuntu:~/Documents/segmentation/segmentation_site$
Can anyone explain what is the right way to run the image docker run command as when this image will be pulled in the deployment location, it can only be run using docker run
command.
Thanks
Remove command: gunicorn -b 0.0.0.0:8000 segmentation_site.wsgi
from your docker-compose.yaml
and put it into your Dockerfile
like this:
CMD gunicorn -b 0.0.0.0:8000 segmentation_site.wsgi
Otherwise the image doesn't start any process
Here is the official Dockerfile documentation for more information.