Hello,
I am trying to dockerize a full application using docker-compose, which has two tiers : db + web app.
Now, since the web app service, needs custom settings, like:
I need to put all those settings in a Dockerfile which is as follows:
FROM php:7.4.12-apache
ENV http_proxy='http://10.60.120.254:8080/'
RUN echo "nameserver 10.55.20.5" > /etc/resolv.conf
RUN apt-get update && apt-get install -y libldap2-dev
CMD bash
But itās always, blocked in the third service, with the following error:
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM php:7.4.12-apache
---> 84973bb59734
Step 2/5 : ENV http_proxy='http://10.60.120.254:8080/'
---> Using cache
---> f7ab9adfcc21
Step 3/5 : RUN echo "nameserver 10.55.20.5"
---> Using cache
---> 3334de78d241
Step 4/5 : RUN apt-get update && apt-get install -y libldap2-dev
---> Running in 26318a55853b
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Err:1 http://security.debian.org/debian-security buster/updates InRelease
At least one invalid signature was encountered.
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Err:2 http://deb.debian.org/debian buster InRelease
At least one invalid signature was encountered.
Err:3 http://deb.debian.org/debian buster-updates InRelease
At least one invalid signature was encountered.
Reading package lists...
W: GPG error: http://security.debian.org/debian-security buster/updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://security.debian.org/debian-security buster/updates InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian buster InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian buster-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed.
The command '/bin/sh -c apt-get update && apt-get install -y libldap2-dev' returned a non-zero code: 100
I donāt know, whatās really blocking this operation, since i did add nameserver, proxy address for internet connectionā¦
I would like to know, if you can help me here.
Thank you in advance,
I am not sure about the error but I am pretty sure you should not set the nameserver and the proxy inside the container during the build. Usually Docker is running under systemd which you can configure globally: Control Docker with systemd | Docker Documentation
Even if you need to use environment variables, I would use ARG instead of ENV in the dockerfile but that is just a small change.
If you change the content of resolv.conf you will loose that when you run a container from the image.
Now back to the question. Try to investigate this in a simple container instead of building a new image. If it works in a container, it will probably work during the build. Check if you can access any site thorugh the proxy from terminal. Try access the APT repository using curl to check if you see the right page.
Thank you @rimelek for your help!
I did manage to resolve the web app service build, while searching on internet, i found that it might be caused by some corrupt images, so i removed any stale images.
Then, tried to run docker build, and it was successful. Here is the final Dockerfile:
FROM php:7.4.12-apache
ENV http_proxy="http://10.60.120.254:8080"
RUN apt clean
RUN echo "nameserver 10.55.20.5" > /etc/resolv.conf
RUN apt-get update
RUN apt-get install -y libldap2-dev
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install ldap
RUN apt-get install -y libc-client-dev libkrb5-dev && rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap
EXPOSE 80
CMD ["/usr/sbin/apache2ctl","-DFOREGROUND"]
For the DNS, and proxy settings, i do have the docker machine,configured for DNS and proxy services, and it works correctly, but for containers, this did not help whatever i doā¦
So, if you permit to give me some ideas about making it work properly, iād be very grateful.
Thank you so much.
Have you checked the links I gave you? That is how I did it. If you need more advice on it, I recommend you to create a new topic and describe what you have already tried. I remember I had to set the proxy in multiple file but for the containers, I think systemd was enough. I would have to check my old solution to give you more details.