I am trying to get the dordoka/tomcat docker image up and running, but I get this error when running docker build:
Cannot add PPA: 'ppa:~webupd8team/ubuntu/y-ppa-manager'.
ERROR: '~webupd8team' user or team does not exist.
The command '/bin/sh -c apt-get update &&
apt-get install -y software-properties-common &&
add-apt-repository -y ppa:webupd8team/y-ppa-manager &&
add-apt-repository -y ppa:webupd8team/ubuntu/y-ppa-manager &&
apt-get update &&
apt-get install -y git build-essential curl wget software-properties-common'
returned a non-zero code: 1
The command that is failing is add-apt-repository -y ppa:webupd8team/ubuntu/y-ppa-manager. This command runs fine outside of docker. The proxy is configured correctly, as far as I can tell. Any ideas?
#mlowry Is there a particular reason why you have to run this as root?
I assume that when you run it as your user you have also the http_proxy exported ?
In this case you could youse --build-args to pass the http_proxy string.
Quick example:
ubuntu#ip-172-31-10-207:~/test$ docker build --build-arg http_proxy=$http_proxy .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM alpine:latest
---> e21c333399e0
Step 2/4 : ARG http_proxy
---> Running in fd0832692097
Removing intermediate container fd0832692097
---> 4c58ddefe37c
Step 3/4 : RUN export HTTP_PROXY=$http_proxy
---> Running in 913dc802ea8f
Removing intermediate container 913dc802ea8f
---> 9c3280343c13
Step 4/4 : RUN env
---> Running in 0d078193475a
HOSTNAME=0d078193475a
SHLVL=1
HOME=/root
http_proxy=http://domain\user:pass#proxy.com:8080
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
Removing intermediate container 0d078193475a
---> d4b8996fbb09
Successfully built d4b8996fbb09
Related
I have a docker file which has a lot of layers. At the top of the file I have some args like
FROM ubuntu:18.04
ARGS USER=test-user
ARGS UID=1000
#ARGS PW=test-user
# Then several Layers which does not use any ARGS. Example
LABEL version="1.0"
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
RUN mkdir ~/mapped-volume
RUN apt-get update && apt-get install -y wget bzip2 ca-certificates build-essential curl git-core htop pkg-config unzip unrar tree freetds-dev vim \
sudo nodejs npm net-tools flex perl automake bison libtool byacc
# And so on
# And finally towards the end
# Setup User
RUN useradd -m -d /home/${USER} --uid ${UID} -G sudo -s /bin/bash ${USER}
# && echo "${USER}:${PW}" | chpasswd
# Couple of more commands to change dir, entry point etc. Example
When I build this docker file with any arg value different from the last build and/or after small changes in the last two layers, the build builds everything again. It does not use cached layer. The command I use to build is something like this
docker build --build-arg USER=new-user --build-arg UID=$UID -t my-image:1.0 .
And every time I change the values the build goes all through again. With a truncated top like below
UID -t my-image:1.0 .
Sending build context to Docker daemon 44.54kB
Step 1/23 : FROM ubuntu:18.04
---> ccc6e87d482b
Step 2/23 : ARG USER=ml-user
---> Using cache
---> 6c0c5d5c5056
Step 3/23 : ARG UID=1000
---> Using cache
---> b25867c282c7
Step 4/23 : LABEL version="1.0"
---> Running in 1ffff70d56c1
Removing intermediate container 1ffff70d56c1
---> 0f1277def3ca
Step 5/23 : ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
---> Running in 49d08c41b233
Removing intermediate container 49d08c41b233
---> f5b345573c1f
Step 6/23 : RUN mkdir ~/mapped-volume
---> Running in e4f8a5956450
Removing intermediate container e4f8a5956450
---> 1b22731d9051
Step 7/23 : RUN apt-get update && apt-get install -y wget bzip2 ca-certificates build-essential curl git-core htop pkg-config unzip unrar tree freetds-dev vim sudo nodejs npm net-tools flex perl automake bison libtool byacc
---> Running in ffc297de6234
Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
So from step 7 it keeps doing all steps without using the cache of that layer which should have a bunch of packages
Why? How can I stop this? Previously when I did not have args, this layer and other layers used to be picked up from cache.
Move your args to just before you need them. Docker does not replace args in the RUN commands before running them. Instead, the args are passed as environment variables and expanded by the shell within the temporary container. Because of that, a change to an arg is a change to the environment, and a miss of the build cache for that step. Once one step misses the cache, all following steps must be rebuilt.
FROM ubuntu:18.04
# Then several Layers which does not use any ARGS. Example
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
RUN mkdir ~/mapped-volume
RUN apt-get update && apt-get install -y wget bzip2 ca-certificates build-essential curl git-core htop pkg-config unzip unrar tree freetds-dev vim \
sudo nodejs npm net-tools flex perl automake bison libtool byacc
# And so on
# And finally towards the end
# Setup User
ARGS USER=test-user
ARGS UID=1000
RUN useradd -m -d /home/${USER} --uid ${UID} -G sudo -s /bin/bash ${USER}
# && echo "${USER}:${PW}" | chpasswd
# Couple of more commands to change dir, entry point etc. Example
LABEL version="1.0"
Also, labels, environment variables that aren't needed at build time, exposed ports, and any other meta data is often best left to the end of the Dockerfile since they have minimal impact on build time and there's no need to miss the cache when they change.
I'm learning Docker and I've been crafting a Dockerfile for an Ubuntu container.
My problem is I keep getting persistent information between different containers. I have exited, removed the container and then removed its image. After I made changes to my Dockerfile, I executed docker build -t playbuntu . Executing the following Dockerfile:
FROM ubuntu:latest
## for apt to be noninteractive
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
## preesed tzdata, update package index, upgrade packages and install needed software
RUN echo "tzdata tzdata/Areas select Europe" > /tmp/preseed.txt; \
echo "tzdata tzdata/Zones/Europe select London" >> /tmp/preseed.txt; \
debconf-set-selections /tmp/preseed.txt && \
apt-get update && \
apt-get install -y tzdata
RUN apt-get update -y && apt-get upgrade -y && apt-get install tree nano vim -y && apt-get install less -y && apt-get install lamp-server^ -y
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
EXPOSE 80
WORKDIR /var/www
COPY ./index.php /var/www
COPY ./000-default.conf /etc/apache2/sites-available
CMD [ "apache2ctl", "start", "&&", "apache2ctl", "restart" ]
Once I execute winpty docker run -it -p 80:80 playbuntu bash, my problem is, instead of my index.php file outputting the following:
<?php
print "<center><h3>Sisko's LAMP activated!</h3><center>";
phpinfo();
I get the following debug code I experimented with hours ago:
<?php
print "...responding";
phpinfo();
Is there a caching system Docker might be using? I pruned all Docker volumes just in case that is how Docker might be caching. All except 2 volumes which are being used by other containers unrelated to my project.
I suspect that, after you changed index.php on your host machine you did not rerun the docker build ... command. You will need to recreate the container image any time any of the image's content changes.
Please confirm whether running the docker build ... command again solves the issue.
Background
Docker images comprise one of more layers.
Image (layers) and Volumes are distinct.
Since your docker run ... command contains no e.g. --volume= bind mounts (or equivalent), I suspect Docker Volumes are not relevant to this question.
There is a possibility that rebuilding images does not replace image layers and thus caching does occur. However, in your case, I think this is not the issue. See the Docker documentation (link) for an overview of the Dockerfile commands that add layers.
Because of the way that layers work, if the preceding layers in your Dockerfile were unchanged and the index.php were unchanged, then Docker would not rebuild these layers. However, because your Dockerfile includes a layer that apt-get update && apt-get install ...., the layer will be invalidated, recreated and so will subsequent layers.
If you change index.php on the host and rebuild the image, this layer will always be rebuilt.
I built your Dockerfile twice. Here's the beginning of the second (!) build command. NB the Using cache commands for the unchanged layers preceding the RUN apt-get update... layer which is rebuilt.
docker build --rm -f "Dockerfile" -t 59582820:0939 "."
Sending build context to Docker daemon 3.584kB
Step 1/10 : FROM ubuntu:latest
---> 549b9b86cb8d
Step 2/10 : ENV DEBIAN_FRONTEND noninteractive
---> Using cache
---> 1529d0e293f3
Step 3/10 : ENV DEBCONF_NONINTERACTIVE_SEEN true
---> Using cache
---> 1ba10410d06a
Step 4/10 : RUN echo "tzdata tzdata/Areas select Europe" > /tmp/preseed.txt; echo "tzdata tzdata/Zones/Europe select London" >> /tmp/preseed.txt; debconf-set-selections /tmp/preseed.txt && apt-get update && apt-get install -y tzdata
---> Using cache
---> afb861da52e4
Step 5/10 : RUN apt-get update -y && apt-get upgrade -y && apt-get install tree nano vim -y && apt-get install less -y && apt-get install lamp-server^ -y
---> Running in 6f05bbb8e80a
The evidence suggests to me that you didn't rebuild after changing the index.php.
You can use volumes to persist some folders like configs or properties etc. Docker Storage
When I am running the build command:
$ docker build -t cowsay .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM
Unknown instruction: FROM
dev#ub:~/cowsay$ docker build -t cowsay .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM ubuntu:14.04
---> 90d5884b1ee0
Step 2 : RUN apt-get -y install cowsay
---> Running in 587aaba2824b
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package cowsay
The command '/bin/sh -c apt-get -y install cowsay' returned a non-zero code: 100
Content of Dockerfile is as follow:
FROM ubuntu:14.04
RUN apt-get -y install cowsay
RUN apt-get -y install fortune
ENTRYPOINT ["/usr/games/cowsay"]
CMD ["Docker is so awesomoooooooo!"]
ONBUILD RUN /usr/games/fortune | /usr/games/cowsay
How can I avoid this error message?
Try and add RUN apt-get update first.
Once the packages are updated, you can install, for instance, cowsay.
See for instance this Dockerfile as an example of RUN apt-get commands:
FROM debian:jessie
RUN apt-get update && apt-get install -y cowsay
COPY docker.cow /usr/share/cowsay/cows/docker.cow
ENTRYPOINT ["/usr/games/cowsay","-f","docker"]
CMD ["moby","dock"]
I am trying to install the 'sl' package in my ubuntu:14.04 image. Here's the content of my Dockerfile :
FROM ubuntu:14.04
MAINTAINER xyz <xyz#gmail.com>
RUN echo 'Going to install sl now'
RUN apt-get install -y sl
And this is the command I'm using to build the image:
sudo docker build -t xyz/ubuntu:14.04 .
But I'm getting this error message:
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04
---> d0955f21bf24
Step 1 : MAINTAINER xyz <xyz#gmail.com>
---> Using cache
---> a6e08926e788
Step 2 : RUN echo 'Going to install sl now'
---> Using cache
---> 1bf0bc6b3092
Step 3 : RUN apt-get install -y sl
---> Running in f7e57167443f
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package sl
INFO[0004] The command [/bin/sh -c apt-get install -y sl] returned a non-zero code: 100
Where am I going wrong?
You need to run apt-get update e.g:
RUN apt-get update && apt-get install -y sl
You can also tidy up after yourself to save a bit of disk space:
RUN apt-get update && apt-get install -y sl && rm -r /var/lib/apt/lists/*
You need to update indices on your local ubuntu repository before installing any other package. The right way to do this will be:
RUN apt-get update
RUN apt-get install -y <package-name>
As Adrian mentioned in his answer deleting the downloaded list can be used to save some space on the disk. This is especially helpful when you are pushing the image back to the hub.
I'm trying to build the following Dockerfile:
FROM ubuntu-debootstrap:trusty
ENV CONFD_VERSION 0.6.3
ENV CONFD_INTERVAL 30
ENV CONFD_NODE 172.17.42.1:4001
ENV CONFD_BACKEND etcd
RUN apt-get update -q \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y -q nginx \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists
ADD https://github.com/kelseyhightower/confd/releases/download/v0.6.3/confd-0.6.3-linux-amd64 /usr/local/bin/confd
RUN chmod +x /usr/local/bin/confd /usr/local/bin/confd
EXPOSE 80
CMD confd -verbose -interval $CONFD_INTERVAL -backend $CONFD_BACKEND -node $CONFD_NODE
But it fails trying to fetch the remote file with a 'too many redirects' error:
$ docker build -t confdrouter .
Sending build context to Docker daemon 16.9 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu-debootstrap:trusty
---> 21530629f1e1
Step 1 : ENV CONFD_VERSION 0.6.3
---> Using cache
---> 070ff91dc728
Step 2 : ENV CONFD_INTERVAL 30
---> Using cache
---> 2d30a2f30f85
Step 3 : ENV CONFD_NODE 172.17.42.1:4001
---> Using cache
---> 96915c53a9aa
Step 4 : ENV CONFD_BACKEND etcd
---> Using cache
---> 5d770c929056
Step 5 : RUN apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -y -q nginx && apt-get clean && rm -rf /var/lib/apt/lists
---> Using cache
---> 5c2465522a1c
Step 6 : ADD https://github.com/kelseyhightower/confd/releases/download/v0.6.3/confd-0.6.3-linux-amd64 /usr/local/bin/confd
2014/11/07 11:31:57 Get https://s3.amazonaws.com/github-cloud/releases/13234395/5e2257d4-4f46-11e4-92c7-d029c6449976.3-linux-amd64?response-content-disposition=attachment%3B%20filename%3Dconfd-0.6.3-linux-amd64&response-content-type=application/octet-stream&AWSAccessKeyId=AKIAISTNZFOVBIJMK3TQ&Expires=1415381577&Signature=WWdGHk8K3%2BIQyl7Cl4UcBN8aDQM%3D: dial tcp: lookup s3.amazonaws.com on [10.0.2.3]:53: too many redirects
Running boot2docker 1.3.1 on Mac OS X 10.10. Any idea what is going on here?
Looks like the error is coming from DNS, and the DNS server is at 10.0.2.3. This is the address that VirtualBox maps for DNS.
Very similar question at How to fix Docker's "Error pulling image...too many redirects" failures while pulling images from registry?, with advice to use Google's DNS at 8.8.8.8, which is generally excellent.