How to set an environment variable in a running docker container

前端 未结 11 1163
难免孤独
难免孤独 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:05

    You could set an environment variable to a running Docker container by

    docker exec -it -e "your environment Key"="your new value" /bin/bash

    Verify it using below command

    printenv

    This will update your key with the new value provided.

    Note: This will get reverted back to old on if docker gets restarted.

提交回复
热议问题