How to Resolve Docker WARNING: IPv4 forwarding is disabled. Networking will not work.

If you have freshly deployed Docker for testing and learning purpose, you might get this error while trying to launch a Docker container. The main cause of this issue is that IP forwarding is not enabled in the host running your container, so a simple solution would be to enable this settings in the sysctl config file of your server. It is worth noting though, that this procedure alone might not work all the time, and many suggested workarounds to this issue were to do some cleaning, by removing all your existing containers and private networks in your Docker host.

In my case I was playing with Docker installed on CentOS 7 in a nested development environment, so doing so was not a big deal for me. Obviously, you might think twice if you have to do it in a production box.

The error looks like this while trying to spin off your container, and this basically means that you will not be able to access Internet from your container or make it communicate with your host or other containers, because such kind of communication relies on IP forwarding to work.

The resolution steps to follow are:

  • Enable IP forwarding permanently

  • Restart Network Service

After IP forwarding is enabled, you should be able to run your container. If the error is still there, you might want to proceed the hard way by doing some cleaning.

  • Remove all existing containers

  • Remove all of existing networks

  • Remove Docker networking metadata

  • Restart Docker service

After going through these steps, I was able to run my container without any issue

Cleaning all containers does not sounds like a good idea, and I agree. That’s why before spinning-off any container on a newly installed Docker host, make sure the sure the IP forwarding is enabled. If you’re using a nested environment for your Docker learning purpose, this will let you focusing more on your Docker testing than exploring the different ways to troubleshoot a non supported environment, as stated by Docker here.

Find this post interesting. Share it!

Leave a Comment

Your email address will not be published. Required fields are marked *