更改Docker现有容器实例的环境变量 - 使用WSL2使用Docker桌面
我正在尝试将环境变量“ RAM”更改为 8 ,因此,对于特定现有的容器,基本上将容器升级到8GB RAM。
变量最初设置的方式是通过docker run -e ram = 4
命令。但是,如果我再次运行“ dock运行”,它将创建另一个容器实例。我不想这样做,因为我已经在原始容器中设置/配置了OS。
无论如何,是否可以在不创建新容器的情况下更改容器的环境变量?顺便说一句,我将Docker用于Winding with Wsl2,
以下是 docker Inspect 的部分
"Env": [
"DISPLAY=172.16.22.8:0.0",
"EXTRA=-display none -vnc 0.0.0.0:99,password=off",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=en_US.UTF-8",
"USER=arch",
"SUPERMIN_KERNEL=/boot/vmlinuz-linux",
"SUPERMIN_MODULES=/lib/modules/5.12.14-arch1-1",
"SUPERMIN_KERNEL_VERSION=5.12.14-arch1-1",
"KERNEL_PACKAGE_URL=https://archive.archlinux.org/packages/l/linux/linux-5.12.14.arch1-1-x86_64.pkg.tar.zst",
"KERNEL_HEADERS_PACKAGE_URL=https://archive.archlinux.org/packages/l/linux/linux-headers-5.12.14.arch1-1-x86_64.pkg.tar.zst",
"LIBGUESTFS_PACKAGE_URL=https://archive.archlinux.org/packages/l/libguestfs/libguestfs-1.44.1-6-x86_64.pkg.tar.zst",
"LIBGUESTFS_DEBUG=1",
"LIBGUESTFS_TRACE=1",
"ADDITIONAL_PORTS=",
"BASESYSTEM_FORMAT=qcow2",
"BOOT_ARGS=",
"BOOTDISK=",
"CPU=Penryn",
"CPUID_FLAGS=vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,",
"ENV=/env",
"GENERATE_UNIQUE=false",
"GENERATE_SPECIFIC=false",
"IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img",
"IMAGE_FORMAT=qcow2",
"KVM=accel=kvm:tcg",
"MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist",
"NETWORKING=vmxnet3",
"NOPICKER=false",
"RAM=4",
"WIDTH=1920",
"HEIGHT=1080"
],
I'm trying to change environment variable "RAM" to 8, so basically upgrade the container to 8GB of RAM for a specific existing container.
The way the variable was originally set was through docker run -e RAM=4
command for example. However, if I run "dock run" again it creates another container instance. I don't want to do this because I have already setup/configured the OS in the original container.
Is there anyway to change this environment variable for the container without creating a new container? By the way I'm using Docker for Windows with WSL2
The below is section from docker inspect
"Env": [
"DISPLAY=172.16.22.8:0.0",
"EXTRA=-display none -vnc 0.0.0.0:99,password=off",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=en_US.UTF-8",
"USER=arch",
"SUPERMIN_KERNEL=/boot/vmlinuz-linux",
"SUPERMIN_MODULES=/lib/modules/5.12.14-arch1-1",
"SUPERMIN_KERNEL_VERSION=5.12.14-arch1-1",
"KERNEL_PACKAGE_URL=https://archive.archlinux.org/packages/l/linux/linux-5.12.14.arch1-1-x86_64.pkg.tar.zst",
"KERNEL_HEADERS_PACKAGE_URL=https://archive.archlinux.org/packages/l/linux/linux-headers-5.12.14.arch1-1-x86_64.pkg.tar.zst",
"LIBGUESTFS_PACKAGE_URL=https://archive.archlinux.org/packages/l/libguestfs/libguestfs-1.44.1-6-x86_64.pkg.tar.zst",
"LIBGUESTFS_DEBUG=1",
"LIBGUESTFS_TRACE=1",
"ADDITIONAL_PORTS=",
"BASESYSTEM_FORMAT=qcow2",
"BOOT_ARGS=",
"BOOTDISK=",
"CPU=Penryn",
"CPUID_FLAGS=vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,",
"ENV=/env",
"GENERATE_UNIQUE=false",
"GENERATE_SPECIFIC=false",
"IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img",
"IMAGE_FORMAT=qcow2",
"KVM=accel=kvm:tcg",
"MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist",
"NETWORKING=vmxnet3",
"NOPICKER=false",
"RAM=4",
"WIDTH=1920",
"HEIGHT=1080"
],
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您并不是要覆盖运行容器的环境变量,您应该停止运行一个,并启动一个具有新环境变量的新的环境变量:)
无论如何,容器应该是抛弃的东西!
I think you are not meant to overwrite environment variables for a running container, you should just stop the running one and start a new one with new environment variables :)
Containers are supposed to be throw-away things anyway!