I have been following a tutorial (https://www.youtube.com/watch?v=nh1ynJGJuT8) to deploy a django project to docker. Both docker files work independently but when I run the docker-compose-deploy.yml I get the following error:
Attaching to app_1, proxy_1
app_1 |
app_1 | 128 static files copied to '/vol/web/static', 3 unmodified.
app_1 | Error loading shared library libxml2.so.2: No such file or directory (needed by /usr/local/bin/uwsgi)
app_1 | Error relocating /usr/local/bin/uwsgi: xmlDocSetRootElement: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlCheckVersion: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlNewTextChild: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlNewChild: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlNewDoc: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlReadMemory: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlNewNode: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlDocDumpFormatMemory: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlCleanupParser: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlFreeDoc: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlDocGetRootElement: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlGetProp: symbol not found
app_1 | Error relocating /usr/local/bin/uwsgi: xmlFree: symbol not found
proxy_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
proxy_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
proxy_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
app_1 exited with code 127
proxy_1 | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
proxy_1 | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
proxy_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
proxy_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
proxy_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
proxy_1 | 2021/06/09 10:57:59 [emerg] 1#1: host not found in upstream "app" in /etc/nginx/conf.d/default.conf:9
proxy_1 | nginx: [emerg] host not found in upstream "app" in /etc/nginx/conf.d/default.conf:9
proxy_1 exited with code 1
I tried to add both libxml2 and libxml2-dev to the Dockerfile but it still presents this error. Here are the dockerfiles and the docker compose:
docker-compose.yml
version: '3.7'
services:
app:
build:
context: .
volumes:
- static_data:/vol/web
environment:
- SECRET_KEY=samplesecretkey123
- ALLOWED_HOSTS=127.0.0.1,localhost
proxy:
build:
context: ./proxy
volumes:
- static_data:/vol/static
ports:
- "8080:8080"
depends_on:
- app
volumes:
static_data:
.Dockerfile:
FROM python:3.8-alpine
ENV PATH="/scripts:${PATH}"
COPY ./requirements.txt /requirements.txt
RUN apk add --update --no-cache --virtual .tmp gcc libc-dev linux-headers libxml2 libxml2-dev libxslt-dev python3-dev gcc build-base libffi-dev
RUN pip install -r /requirements.txt
RUN apk del .tmp
RUN mkdir /app
COPY ./app /app
WORKDIR /app
COPY ./scripts /scripts
RUN chmod +x /scripts/*
RUN mkdir -p /vol/web/media
RUN mkdir -p /vol/web/static
RUN adduser -D user
RUN chown -R user:user /vol
RUN chmod -R 755 /vol/web
USER user
CMD ["entrypoint.sh"]
./proxy/Dockerfile
FROM nginxinc/nginx-unprivileged:1-alpine
COPY ./default.conf /etc/nginx/conf.d/default.conf
COPY ./uwsgi_params /etc/nginx/uwsgi_params
USER root
RUN mkdir -p /vol/static
RUN chmod 755 /vol/static
Please let me know if any more information is required. As I said, the docker files work independently