I have this docker run command:
docker run --rm --name=gitleaks \
-v "/keys/ssh/values:/root/.ssh" \
zricethezav/gitleaks \
--ssh-key='bucket' \
--repo "$line"
I tranlated it to this:
docker create zricethezav/gitleaks --name=gitleaks
docker cp /keys/ssh/values gitleaks:/root/.ssh
docker start gitleaks --ssh-key='bucket' --repo "$line"
but it gives me this error:
Error: No such container:path: gitleaks:/root unknown flag: --ssh-key
Does anybody know where I went wrong? Ultimately I am calling docker run from within a running container and am having trouble sharing files, so trying to get docker cp
to work.
Issue is with your first and second command syntax.
docker create zricethezav/gitleaks --name=gitleaks
--name
should be before image name, otherwise docker create
will interpret it as COMMAND argument instead of OPTIONS flag.
docker start gitleaks --ssh-key='bucket' --repo "$line"
I understand you want to run the image with parameters --ssh-key and --repo, however it's not possible with docker start
command. If you want to have these parameters passed to the process run by the image, you should pas these parameters to docker create
or docker run
command after the image name.
So you should do:
# Mind the --name before the image name
docker create --name=gitleaks zricethezav/gitleaks --ssh-key='bucket' --repo "$line"
docker cp /keys/ssh/values gitleaks:/root/.ssh
docker start gitleaks
Explanations for docker create:
docker create
usage is:
docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
Where OPTIONS
flags should be specified before IMAGE
, and everything after IMAGE
will be interpreted as COMMAND
and ARG...
.
When you are running
docker create zricethezav/gitleaks --name=gitleaks
You are in fact passing --name=gitleaks
as COMMAND
which will override default image command (the one tipycally provided by CMD
in Dockerfile), where you probably want to pass it as OPTIONS
. For example, if you run:
docker create alpine --name=foobar
docker create --name=foobar alpine
docker ps -a
output will look like:
IMAGE COMMAND NAMES
alpine "/bin/sh" foobar
alpine "--name=foobar" quirky_varahamihira
If you want to pass both OPTIONS
and COMMAND
, you must specify OPTIONS
before the image name and COMMAND
after the image name.
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