-
Can't pull image from Docker Hub or other registries
- Check your internet connection.
- Validate if Docker daemon is running:
systemctl status docker
- Confirm your DNS settings:
cat /etc/resolv.conf
- Use a different DNS in Docker:
/etc/docker/daemon.json
should look like this:Then restart Docker:{ "dns": ["8.8.8.8", "8.8.4.4"] }
sudo systemctl restart docker
-
Containers can't reach the internet
- Check if the container has an IP:
docker inspect -f '{{ .NetworkSettings.IPAddress }}' container_name_or_id
- Check network configuration for the container:
docker network inspect bridge
- Ping an external IP to verify internet connectivity from within the container:
docker exec -it container_name_or_id ping 8.8.8.8
- Check if the container has an IP:
-
Inter-container communication isn't working
- Check if containers are in the same network:
docker network inspect network_name
- Check if Docker's built-in DNS is resolving container names correctly by pinging the target container.
- Check if containers are in the same network:
-
Network errors when trying to link containers
- Check if the
--link
flag was used correctly. It's often better to use user-defined networks over default networks for container communication.
- Check if the
-
IP Forwarding
- Make sure that the host machine has IP forwarding enabled:
sysctl net.ipv4.ip_forward
(1 indicates it's enabled) - If not enabled, you can enable it with:
sysctl -w net.ipv4.ip_forward=1
- Make sure that the host machine has IP forwarding enabled:
-
Firewalld Issues
- Check status:
sudo firewall-cmd --state
- Add docker to trusted zones:
sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0
- Reload firewalld:
sudo firewall-cmd --reload
- Check status:
-
SELinux Issues
- Check SELinux status:
getenforce
orsestatus
- You may have to set SELinux in permissive mode temporarily for troubleshooting:
sudo setenforce 0
- Make sure to understand the security implications before disabling or adjusting SELinux settings.
- No, seriously, setting to permissive mode should only be a temporary measure.
- Check SELinux status:
-
DNS Resolution Issues on the Host
- Check your DNS settings in
/etc/resolv.conf
- Try to manually resolve addresses using
dig
ornslookup
:dig @dns_server_ip domain_to_resolve
- If DNS settings have been recently changed, you might need to flush DNS cache. Ubuntu doesn't cache DNS queries by default, but if caching is enabled via
dnsmasq
orsystemd-resolved
, you'll need to flush it.
- Check your DNS settings in
-
Routing Issues on the Host
- Check your routing table with
ip route
- If the destination is not in the same subnet, make sure there's a route to it or a default route is available.
- Check if there's a correct NAT rule if using NAT:
iptables -t nat -L
- Confirm that the interface you're using is up:
ip link
- Ensure that the interface has the correct IP address:
ip addr
- Check your routing table with
-
Check Docker Network
- View details:
docker network inspect network_name
- Ensure the network isn't private.
- Check for the correct subnet and gateway.
- Check if the containers in the network have correct IP addresses assigned.
- View details:
-
DNS Issues in Docker
- Containers not able to resolve DNS.
- Check
/etc/resolv.conf
inside the container. - If necessary, you can override the DNS settings for a container or for Docker daemon.
-
Routing Issues
- Incorrect or missing route to a network.
- Check route on host using
ip route
and inside the container usingdocker exec -it container_name_or_id ip route
. - Check if there's a correct route to the destination.
-
Can't access exposed ports on container from outside host
- Check if the port was exposed correctly during container creation (
-p
or-P
flag). - Check if the application inside the container is actually listening on the exposed port.
- Ensure there are no host-level firewall rules blocking inbound connections.
- Check if the port was exposed correctly during container creation (
-
Can't access service running on the host from within a container
- For user-defined bridge networks or custom networks, you can access the host using the gateway's IP.
- You can also use
host.docker.internal
as the hostname to refer to the host system from the container.
-
Swarm Services not accessible from outside
- Check if the service's ports were correctly published during service creation (
--publish
flag). - Validate if Docker Swarm mode is active:
docker info | grep Swarm
- Check if the service's ports were correctly published during service creation (