Reputation: 119
I want to be able to run a docker run...
command for my custom Ubuntu command where the docker will run two commands as if they were typed once the docker begins running. I have my docker mounted to a local folder and have a custom code within the mounted folder, I want running the docker to also run cd Project
and ./a.out
within the docker but I am not sure how to do that in one long command.
I have tried docker run --mount type=bind,source="/home/ec2-user/environment/Project",target="Project" myubuntu cd Project && ./a.out
but I get an OCI runtime create failed.
I have also tried docker run --mount type=bind,source="/home/ec2-user/environment/Project",target="Project" myubuntu -c 'cd Project && ./a.out'
but get the same error.
Ultimately, it would be nice to have my mounted directory, cd Project, ./a.out
, and exit command in my Dockerfile so that the docker container opens, runs the compiled code within a.out
, and then exits with a simple docker run myubuntu
command but I know that mounting within the Dockerfile requires the image be rebuilt every time that local folder changes. So that leaves me with being able to open the docker container, run my two commands, and exit the container with 1 docker run
command line.
Upvotes: 0
Views: 802
Reputation: 207818
I think you want to start a shell that runs your two commands:
docker run --mount ... myubuntu /bin/bash -c 'cd somewhere && do something'
Upvotes: 1