Error setting environment variable in docker container

Summary

I’m trying to run a command outside of a running docker container to set some environment variables in that container.

Here’s the command for spinning up the container and have it running in the background:

docker run -dt --net=host --name scheduler some/image

Now that I want to set an environment variable inside the container, I get the error message:

> docker exec -t scheduler export LMAO=1
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"export\": executable file not found in $PATH": unknown

If I do something other than export, it goes through normally, like this:

> docker exec -t scheduler echo lmao
lmao

Also, note that when I use docker exec -it scheduler bash to go inside the container and do export LMAO=1, it works just fine.

Expected behavior

To set the environment variable without any error messages

Actual behavior

An error message that says “executable file not found in $PATH” – see above

Steps to reproduce the behavior

  1. Have a docker container running in the background
  2. Try to set up an environment variable using export VAR=value from outside of the container

Additional Information

Docker version

> docker version
Client: Docker Engine - Community
 Version:           19.03.13
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        4484c46d9d
 Built:             Wed Sep 16 17:02:36 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.13
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       4484c46d9d
  Built:            Wed Sep 16 17:01:06 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.7
  GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
  • OS: Linux 5.3.0-1032-azure x86_64; Ubuntu 18.04.4
  • Please let me know if I need to provide more information!