How to set an environment variable in a running docker container

前端 未结 11 1177
难免孤独
难免孤独 2020-11-29 23:28

If I have a docker container that I started a while back, what is the best way to set an environment variable in that running container? I set an environment variable initia

11条回答
  •  盖世英雄少女心
    2020-11-30 00:02

    For a somewhat narrow use case, docker issue 8838 mentions this sort-of-hack:

    You just stop docker daemon and change container config in /var/lib/docker/containers/[container-id]/config.json (sic)

    This solution updates the environment variables without the need to delete and re-run the container, having to migrate volumes and remembering parameters to run.

    However, this requires a restart of the docker daemon. And, until issue issue 2658 is addressed, this includes a restart of all containers.

提交回复
热议问题