Issue
I've ssh'd into a remote server and need to enter a running docker container and add a superuser.
I can run docker exec -it <container_id> ls
and see the contents of the docker container (/bin
, /dev
, docker-entrypoint.sh
etc).
From here, how do I run my python command python manage.py createsuperuser
?
When I try docker exec -it <container_id> python manage.py createsuperuser
I get the following error:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "python": executable file not found in $PATH: unknown
When I try docker exec -it <container_id> sh python manage.py createsuperuser
, I get the following error:
sh: can't open 'python': No such file or directory
Solution
Root cause of my problem was an incorrect container id. Answering this question to list out the working steps, even though @chepner's comment helped diagnose the issue.
ssh <remote_address>
cd <application_dir>
cd src
docker ps # to identify the correct container ID
docker exec -it <container_id> ls src # to confirm manage.py is present
docker exec -it <container_id> sh
cd src
python manage.py createsuperuser
Answered By - Asa Answer Checked By - Cary Denson (WPSolving Admin)