Docker Community Forums

Share and learn in the Docker community.

RUN add-apt-repository makes error


(Mesobius) #1

Hi all,

newer on Docker, i’m trying to create a new container from ubuntu 16.04, with nginx, php7.1 and other littles software.

I encounter a error during building from Dockerfile

Here my docker file :

FROM ubuntu:16.04
MAINTAINER mesobius
ENV REFRESHED_AT 2018-01-25
RUN apt-get -y update
RUN apt-get -y install curl nano wget
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y composer
RUN apt-get install -y nginx
RUN apt-get install -y software-properties-common
RUN apt-get install -y python-software-properties
RUN add-apt-repository -y ppa:ondrej/php
RUN apt-get update
RUN apt install -y --no-install-recommends php7.1 php7.1-fpm php7.1-mysql php7.1-curl php7.1-json php7.1-gd php7.1-mcrypt php7.1-msgpack php7.1-memcached php7.1-intl php7.1-sqlite3 php7.1-gmp php7.1-geoip php7.1-mbstring php7.1-redis php7.1-xml php7.1-zip
ADD build/start.sh /root/start.sh
RUN chmod +X /root/start.sh
ADD build/nginx.conf /etc/nginx/sites-available/default
EXPOSE 80

The error appear at the bold line :

RUN add-apt-repository -y ppa:ondrej/php

the error is :

Step 14/21 : RUN add-apt-repository -y ppa:ondrej/php
—> Running in f59aa3b4d3b4
gpg: keyring /tmp/tmpfr6dbhie/secring.gpg' created gpg: keyring/tmp/tmpfr6dbhie/pubring.gpg’ created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpfr6dbhie/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key “Launchpad PPA for Ond\xc5\x99ej Sur�” imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
‘ascii’ codec can’t decode byte 0xc5 in position 92: ordinal not in range(128)
The command ‘/bin/sh -c add-apt-repository -y ppa:ondrej/php’ returned a non-zero code: 1

I don’t understand why I get this error.
If I enter in interactive mode and do this command “manually”, the code is executed without error.

If someone have an idea…

Sorry if I create this topic in the wrong section.

Thanks.


(Sam) #2

i might run the apt-get update before you do the apt add… and then after…
also, you can do all those prior installs as one statement, rather than individually


(Mesobius) #3

I tried apt-get update before and after, same problem, same error on the same line …


(Sam) #4

see https://askubuntu.com/questions/393638/unicodedecodeerror-ascii-codec-cant-decode-byte-0x-in-position-ordinal-n

seems to be that the locale is not setup completely at docker build time


(Mesobius) #5

OK, so I had found a solution, probably not the most esthetic, but it works :

to follow your advise, I added RUN export LANG=en_US.UTF-8 to my dockerfile, but it seem to not be enough.

I had grouped those 3 commands

add-apt-repository -y ppa:ondrej/php
apt-get update
apt install -y –allow-unauthenticated --no-install-recommends php7.1 php7.1-fpm php7.1-mysql php7.1-curl php7.1-json php7.1-gd php7.1-mcrypt php7.1-msgpack php7.1-memcached php7.1-intl php7.1-sqlite3 php7.1-gmp php7.1-geoip php7.1-mbstring php7.1-redis php7.1-xml php7.1-zip

in one setup.sh script. I had copy this file in my container and execute it at the same time than equivalent RUN lines
when executing this script a new error appeared : an authentication error on php7 repository. I need to include the - -allow-unauthenticated in the apt-get install.
And then the build works well.
Thanks for bring me on a right way.
BRs