For instance if I have a run command like this:
docker run --name yo -v "$(pwd)":/usr/src/myapp -w /usr/src/myapp ubuntu sh tmp.sh
If I run it again, it spits out this error:
Error response from daemon: Conflict, the name yo is already assigned to c23849234e. You have to delete (or rename) that container to be able to assign yo to a container again.
It works with docker start though:
docker start -ia yo
So I just want to do one or the other.
Simple answer, use the shells || operation. So if run
fails, it will start
instead:
docker run --name yo -v $PWD:/usr/src/myapp -w /usr/src/myapp ubuntu sh tmp.sh || docker start -ia yo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With