First, some web server such as google.com don't reply to ping commands. If you are able to see that the IP was resolved, then you don't have any problems.
Otherwise, you can check which dns server the container is using by running the command:
docker exec -it <container-name> cat /etc/resolve.conf
If that doesn't show 8.8.8.8
as a configured dns server, you need to do one of the following:
Configure the systemd dns for docker, by creating the file /etc/systemd/system/docker.service.d/dns.conf
with the following content:
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// --dns 8.8.8.8 --dns x.x.x.x --dns x.x.x.x
Alternatively, specify a dns list when starting the container by adding the --dns option to run
docker run --dns 8.8.8.8 ...