I am fairly new to docker and am trying to learn by writing my own images and, for now, reading Docker in action (ISBN: 1633430235)
In both my own code and an example from the book (pg 146) I would like to install git via a dockerfile.
My code:
# set base image
FROM ubuntu:18.04
# author
MAINTAINER me
############## Begin installation ##########################
# update and upgrade
RUN apt-get update
RUN apt-get upgrade
# install git
RUN apt-get install -y git
***rest of code omitted***
Books code:
#An example Dockerfile for installing Git on Ubuntu
FROM Ubuntu:latest
MAINTAINER "dockerinaction@allgeek.com"
RUN apt-get install -y git
ENTRYPOINT ["git"]
However, in both I am getting an unable to locate package eror with a none-zeero code:
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package git
The command '/bin/sh -c apt-get install -y git' returned a non-zero code: 100
So far I have tried.
1) Making apt-get update and apt-get upgrade into a single command. When I do this it fails at this point.
2) Installing apt-transport-https before installing git, as described here:
apt-get update' returned a non-zero code: 100
This will succeed in downloading but as soon as it gets to installing git again, I get the same error. This
3) Following the tutorial on https://docs.docker.com/engine/reference/builder/#dockerfile-examples. Although this is different it still installs the x11 server, again this also fails at installation.
4) Following another answer on stack overflow, Cannot install packages inside docker Ubuntu image I have tried to install curl.
Al these methods, with the exception of the first, let me update & upgrade only to fail once I try to install software. I also have no issues if I am updating, upgrading, installing from a terminal on the machine I am running docker from.
Any advice as to how I can rectify this would be greatly appreciated.