Home  >  Q&A  >  body text

docker - 如何修改运行中容器的配置

我开启一个docker容器:

容器中配置项目IP是:10.241.93.21。
现在由于网络环境的问题,ip地址变化了。需要将容易的IP换成10.241.61.20。

ps:要求不删除现有的容器,下次重启后ip地址还是10.241.61.20。
怎么配置?求方法。谢谢!

滿天的星座滿天的星座2707 days ago1032

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-04-25 09:03:22

    You are using it wrong. Containers should not be permanent things. To keep the container disposable, if there is a problem, it should be removed by rm, the data should be saved outside the container, and then the new container should be run directly. Parameter modifications were made at that time.

    In addition, you should use DNS. If it is an internal machine, you can also use internal DNS instead of hard-coding the IP.

    Both of these approaches have problems. As for modifying the configuration within the container, this is not recommended. The container is not a virtual machine, and the configuration within it should not be modified.

    reply
    0
  • 阿神

    阿神2017-04-25 09:03:22

    Are you using environment variables?

    Look at the priority of environment variables and change the environment variables.

    I’m not sure about the priority of environment variables. You can try to set environment variables by starting files like ~/.bashrc ~./.profile in the user directory

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-04-25 09:03:22

    Have you solved it bro? I have the same problem

    reply
    0
  • Cancelreply