Can't build Docker image using RUN to install git

I'm trying to build a docker image with a Debian base and git installed, but I keep getting an error. Here is the Dockerfile:

FROM debian:stable

RUN apt-get update
RUN apt-get install -y git

And here is the error:

$ docker build . --no-cache
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM debian:stable
 ---> e03ce33c6fd7
Step 2 : RUN apt-get update
 ---> Running in 07b67a2a5c5b
Err:1 http://security.debian.org stable/updates InRelease
  Temporary failure resolving 'security.debian.org'
Err:2 http://deb.debian.org/debian stable InRelease
  Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian stable-updates InRelease
  Temporary failure resolving 'deb.debian.org'
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/stable/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/stable-updates/InRelease  Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/dists/stable/updates/InRelease  Temporary failure resolving 'security.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
 ---> be533607c8ed
Removing intermediate container 07b67a2a5c5b
Step 3 : RUN apt-get install -y git
 ---> Running in eb86bfd94470
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

Can I get some help?