-1

I have a docker container with js application inside. It works fine at any localhost, but when I'm trying to run it on a remote server, it has no internet connection and crashes on the first query. I tried different ways to run, but no option resolved this problem. Any suggestions on how to fix it?

run command is:

docker run --network=host --shm-size=1g --rm -u root --dns 8.8.8.8 --cap-add=NET_ADMIN --cap-add=SYS_ADMIN --device=/dev/net/tun --privileged --sysctl net.ipv6.conf.all.disable_ipv6=0 containerID

I cannot ping IP addresses and resolve names from containers shell

3
  • 1
    what is your docker run command currently?
    – Narzard
    Apr 16, 2019 at 17:58
  • If you run a shell in the container, can you ping IP addresses outside? can you resolve names? what is the firewall configuration on the outside server? (answer by editing your question)
    – xenoid
    Apr 16, 2019 at 19:19
  • do you have IPv4 forwarding enabled? success.docker.com/article/ipv4-forwarding
    – Sathyajith Bhat
    Apr 17, 2019 at 17:09

1 Answer 1

0

I would suggest to debug this by step-by-step, and simplify your docker command while you debugging.

I can guest that your container does not start at all. What's in container logs?

So, if I debug that, I would remove every parameters first and run /bin/bash as a run command in an interactive mode, and check that internet is available from the container:

docker run -it --network=host --shm-size=1g --rm --name=test1 --privileged --entrypoint="" containerID /bin/bash

(containerID is actually the image name or image ID)

if everything is fine, I would suggest to add other parameters one-by-one, and check on which parameter you have the issue.

 -u root
--dns 8.8.8.8
--cap-add=NET_ADMIN
--cap-add=SYS_ADMIN
--device=/dev/net/tun
--sysctl net.ipv6.conf.all.disable_ipv6=0

Another thing is it seems like having the --net=host and --sysctl net.ipv6.conf.all.disable_ipv6=0 is not really right thing, because in that case you'll change parameters of the host machine, because you don't have a separate network stack as when you run without --net=host.

I think that possible reasons of the error are: - your VM provider does not allow to change net.ipv6.conf.all.disable_ipv6=0 - you have problems with your installed packages in Dockerfile (do you use it for building the container, or just upload the container image itself?). you should look at docker logs (probably you need to remove --rm to get them) - you have some mistakes in configs for your application, for example hardcoded IP-addresses, or DNS names, which does not exists in a server-side environment.

I believe that following these steps you can find the actual reason, and solve the problem. Good luck.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .