Dockerfile Error : The repository 'http://security.ubuntu.com/ubuntu cosmic-security Release' does not have a Release file

I get this error from my docker build:

W: The repository 'http://security.ubuntu.com/ubuntu cosmic-security Release' does not have a Release file.

E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/cosmic-security/main/source/Sources  404  Not Found [IP: 91.189.88.149 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/cosmic/main/source/Sources  404  Not Found [IP: 91.189.88.174 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/cosmic-updates/main/source/Sources  404  Not Found [IP: 91.189.88.174 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/cosmic-backports/main/source/Sources  404  Not Found [IP: 91.189.88.174 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service 'web' failed to build: The command '/bin/sh -c requirements="libpng12-dev libmcrypt-dev libmcrypt4 libcurl3-dev libfreetype6 libjpeg-turbo8 libjpeg-turbo8-dev libpng12-dev libfreetype6-dev libicu-dev libxslt1-dev unzip"     && apt-get update     && apt-get install -y $requirements     && rm -rf /var/lib/apt/lists/*   

This is the offending code within my dockerfile ; if it out the code build the images:

RUN requirements="libpng12-dev libmcrypt-dev libmcrypt4 libcurl3-dev libfreetype6 libjpeg-turbo8 libjpeg-turbo8-dev libpng12-dev libfreetype6-dev libicu-dev libxslt1-dev unzip" \
    && apt-get update \
    && apt-get install -y $requirements \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && docker-php-ext-install mbstring \

    && docker-php-ext-install bcmath \
    && requirementsToRemove="libpng12-dev libmcrypt-dev libcurl3-dev libpng12-dev libfreetype6-dev libjpeg-turbo8-dev" \
    && apt-get purge --auto-remove -y $requirementsToRemove

RUN apt-get update \
    && apt-get install -y libmcrypt-dev \
    && yes '' | pecl install mcrypt-1.0.1 \
    && echo 'extension=mcrypt.so' > /usr/local/etc/php/conf.d/mcrypt.ini

I realise that the error seems to say that i need to fetch some source files. but i am unclear how i am suppose to fetch them or how i am suppose to change it

Have you made sure that you have a connection to the host 91.189.88.149 from the docker-host and the docker-client. An easy way to check if you can reach the host just ‘ping’ it. If you can ping the host try the command (on the docker-host) if you can curl to the 91.189… host.

The “Error 404” says that the file you request ist not reachable or not available.