Home  >  Q&A  >  body text

一个运行中的Docker容器怎么修改执行run命令时的环境变量

一个运行中的Docker容器怎么修改执行run命令时的环境变量

PHP中文网PHP中文网2756 days ago769

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-04-25 09:03:19

    Enter the containerdocker exec -it containerId/Names /bin/bash,再使用export修改就可以了吧
    export ENV='value'

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-25 09:03:19

    Hello, it is not recommended to change the configuration of a running container. The container itself is stateless. Of course, it can also be changed by entering the inside of the container:

    docker exec -it <容器id> </bin/bash|/bin/sh>

    Such changes cannot be saved persistently. When the container is restarted, the changes will be lost. The correct approach is to put the data that needs to be persisted in the mounted storage volume, and directly delete and rebuild when the configuration needs to be changed.
    PS: Portal /q/10...

    reply
    0
  • ringa_lee

    ringa_lee2017-04-25 09:03:19

    Thanks for the invitation, there is a very cool thing called docker-gen. You can try to see if it can solve your problem!

    reply
    0
  • Cancelreply