返回首页DA系统C#IDE文件同步服务屏保 今天是: 2026-05-05    "立夏"  夏季的第一个节气,表示盛夏时节的正式开始

搜索
热搜: linux 技术
Hi~登录注册
查看: 2004|回复: 0

[转载] 【转载】“IPv4 forwarding is disabled. Networking will not work” 的解决办法

[复制链接]
发表于 2022-12-19 00:49:43 | 显示全部楼层 |阅读模式

少侠不来段修仙之旅吗~

您需要 登录 才可以下载或查看,没有帐号?注册成为修仙之旅的少年~

x
“IPv4 forwarding is disabled. Networking will not work” 的解决办法
转载地址:https://blog.csdn.net/Tilyp/article/details/90700917


在利用Docker运行Tensorflow Jupyter时遇到了端口号无法开放到外网的情况,错误如下:

  1. [andy@master andy]# nvidia-docker run -it -p 8888:8888 -v /andy/andy/:/notebooks/andy tensorflow:1.8.0-gpu
  2. WARNING: IPv4 forwarding is disabled. Networking will not work.
  3. [I 09:04:03.467 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
  4. [W 09:04:03.480 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
  5. [I 09:04:03.487 NotebookApp] Serving notebooks from local directory: /notebooks
  6. [I 09:04:03.488 NotebookApp] 0 active kernels
  7. [I 09:04:03.488 NotebookApp] The Jupyter Notebook is running at:
  8. [I 09:04:03.488 NotebookApp] http://[all ip addresses on your system]:8888/?token=389603956f0sd6e480f1520ac48e06fd03fab5b6589ff9a097
  9. [I 09:04:03.488 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
  10. [C 09:04:03.488 NotebookApp]
  11.    
  12.     Copy/paste this URL into your browser when you connect for the first time,
  13.     to login with a token:
  14.         http://localhost:8888/?token=389603956f0sd6e480f1520ac48e06fd03fab5b6589ff9a097
复制代码




后来制作镜像时遇到了同样的问题:


  1. [root@master kubeflow]# sudo docker build -t jupyterandy:lasted .
  2. Sending build context to Docker daemon 23.04 kB
  3. Step 1/48 : FROM ubuntu:18.04@sha256:de774a3145f7ca4f0bd144c7d4ffb2931e06634f11529653b23eba85aef8e378
  4. ---> cd6d8154f1e1
  5. Step 2/48 : ARG TF_PACKAGE=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.7.0-cp36-cp36m-linux_x86_64.whl
  6. ---> Using cache
  7. ---> 717397fac736
  8. Step 3/48 : ARG TF_PACKAGE_PY_27=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.7.0-cp27-none-linux_x86_64.whl
  9. ---> Using cache
  10. ---> 1b4a91be6adb
  11. Step 4/48 : ARG TF_SERVING_VERSION=0.0.0
  12. ---> Using cache
  13. ---> 4a8851a836e3
  14. Step 5/48 : ARG TFMA_VERSION
  15. ---> Using cache
  16. ---> 50f5419a137c
  17. Step 6/48 : ARG TFDV_VERSION
  18. ---> Using cache
  19. ---> 8625b6f1d541
  20. Step 7/48 : ARG PIPELINE_SDK_PACKAGE=https://storage.googleapis.com/ml-pipeline/release/0.1.8/kfp.tar.gz
  21. ---> Using cache
  22. ---> 034818e518bb
  23. Step 8/48 : USER root
  24. ---> Using cache
  25. ---> 1419e0dc1449
  26. Step 9/48 : ENV DEBIAN_FRONTEND noninteractive
  27. ---> Using cache
  28. ---> 14d6ccee0ead
  29. Step 10/48 : ENV NB_USER jovyan
  30. ---> Using cache
  31. ---> 1d96a7185474
  32. Step 11/48 : ENV NB_UID 1000
  33. ---> Using cache
  34. ---> ba0433cc7663
  35. Step 12/48 : ENV HOME /home/$NB_USER
  36. ---> Using cache
  37. ---> 6f29aa3bc765
  38. Step 13/48 : ENV NB_PREFIX /
  39. ---> Using cache
  40. ---> 14f9c69f30aa
  41. Step 14/48 : ENV CONDA_DIR /opt/conda
  42. ---> Using cache
  43. ---> a5099ba7d85e
  44. Step 15/48 : ENV PATH $CONDA_DIR/bin:$PATH
  45. ---> Using cache
  46. ---> b29faba8850c
  47. Step 16/48 : ENV TF_PACKAGE $TF_PACKAGE
  48. ---> Using cache
  49. ---> 2fbb397a65a4
  50. Step 17/48 : ENV TF_PACKAGE_27 $TF_PACKAGE_PY_27
  51. ---> Using cache
  52. ---> 4978c1785813
  53. Step 18/48 : ENV TF_SERVING_VERSION $TF_PACKAGE_PY_27
  54. ---> Using cache
  55. ---> 964a507ef780
  56. Step 19/48 : ENV TFMA_VERSION $TFMA_VERSION
  57. ---> Using cache
  58. ---> fcab3a66975e
  59. Step 20/48 : ENV TFDV_VERSION $TFDV_VERSION
  60. ---> Using cache
  61. ---> c39b081b9e94
  62. Step 21/48 : ENV PIPELINE_SDK_PACKAGE $PIPELINE_SDK_PACKAGE
  63. ---> Using cache
  64. ---> 2a019d50a364
  65. Step 22/48 : SHELL /bin/bash -c
  66. ---> Using cache
  67. ---> 83a5233df50b
  68. Step 23/48 : RUN apt-get update && apt-get install -yq --no-install-recommends   apt-transport-https   build-essential   bzip2   ca-certificates   curl   g++   git   gnupg   graphviz   locales   lsb-release   openssh-client   sudo   unzip   vim   wget   zip   && apt-get clean &&   rm -rf /var/lib/apt/lists/*
  69. ---> Using cache
  70. ---> 6b97ff970e9d
  71. Step 24/48 : ENV DOCKER_CREDENTIAL_GCR_VERSION 1.4.3
  72. ---> Using cache
  73. ---> b0af65a68598
  74. Step 25/48 : RUN curl -LO https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v${DOCKER_CREDENTIAL_GCR_VERSION}/docker-credential-gcr_linux_amd64-${DOCKER_CREDENTIAL_GCR_VERSION}.tar.gz &&     tar -zxvf docker-credential-gcr_linux_amd64-${DOCKER_CREDENTIAL_GCR_VERSION}.tar.gz &&     mv docker-credential-gcr /usr/local/bin/docker-credential-gcr &&     rm docker-credential-gcr_linux_amd64-${DOCKER_CREDENTIAL_GCR_VERSION}.tar.gz &&     chmod +x /usr/local/bin/docker-credential-gcr
  75. ---> Using cache
  76. ---> 78a61a3bbed0
  77. Step 26/48 : RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen &&     locale-gen
  78. ---> Using cache
  79. ---> 529a8c9d4baf
  80. Step 27/48 : ENV LC_ALL en_US.UTF-8
  81. ---> Using cache
  82. ---> 2c6567323280
  83. Step 28/48 : ENV LANG en_US.UTF-8
  84. ---> Using cache
  85. ---> 1138658fa36c
  86. Step 29/48 : ENV LANGUAGE en_US.UTF-8
  87. ---> Using cache
  88. ---> 5a89a42ed36e
  89. Step 30/48 : RUN useradd -M -s /bin/bash -N -u $NB_UID $NB_USER &&     chown -R ${NB_USER}:users /usr/local/bin &&     mkdir -p $HOME
  90. ---> Using cache
  91. ---> 9cb2694dd804
  92. Step 31/48 : RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" &&     echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list &&     curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - &&     apt-get update &&     apt-get install -y google-cloud-sdk kubectl
  93. ---> [Warning] IPv4 forwarding is disabled. Networking will not work.
  94. ---> Running in 2d8542485b3f
复制代码




倒数第二行的错误就是因为网络的问题无法下载相关软件,解决办法如下:
修改/etc/sysctl.conf文件,添加如下内容:


  1. net.ipv4.ip_forward=1
复制代码



然后重启网络:

  1. systemctl restart network
复制代码


查看是否添加成功:

  1. sysctl net.ipv4.ip_forward
复制代码


输出为1时则证明是成功的,
之后创建镜像和端口转发都没有问题了



游客
回复
*滑块验证:

DA论坛飞机票来了~
快速回复 返回顶部 返回列表