My command is here:
sudo docker run --name ws_was_con -itd --net=host -p 8022:8022 --restart always account_some/project_some:latest cd /project_directory && daphne -b 0.0.0.0 -p 8022 project_some.asgi:application
but it returns:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "cd": executable file not found in $PATH: unknown.
I have to run with that command cd /project_directory && daphne -b 0.0.0.0 -p 8022 project_some.asgi:application
without CMD on Dockerfile
How can I do that?
3
Answers
You need to provide something to execute your command.
Try:
docker run ... sh -c 'cd /project_directory; daphne -b 0.0.0.0 -p 8022 project_some.asgi:application'
If you’re just trying to run a command in a non-default directory,
docker run
has a-w
option to specify the working directory; you don’t need acd
command.In practice, though, it’s better to put these settings in your image’s Dockerfile, so that you don’t have to repeat them every time you run the application.