tracer tong
tracer tong

Reputation: 553

Docker --name causes ambiguous error

This is a bit of a newb question, but I want to run this docker command:

docker run \
--name $NAME_ASTERISK \
--net=host \
-v $(pwd)/test/example/:/etc/asterisk/ \
-d -t dougbtv/asterisk

It outputs this:

docker: Error response from daemon: Invalid container name (--net=host), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed.

This to me suggests docker believes I am passing the --net line into the --name option and naturally choking on it. This is copy pasted from the project in question (https://github.com/dougbtv/docker-asterisk) so I assume the command is valid (I've rarely worked with multiline commands and I'm not entirely certain on the syntax).

Are there any obvious issues with this command?

Upvotes: 0

Views: 1005

Answers (1)

BMitch
BMitch

Reputation: 264986

$ docker run \
  --name $NAME_ASTERISK \
  --net=host \
  -v $(pwd)/test/example/:/etc/asterisk/ \
  -d -t dougbtv/asterisk

docker: Error response from daemon: Invalid container name (--net=host), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed.

This indicates the first argument docker sees after --name is --net=host. If $NAME_ASTERISK is undefined or empty, that will be the case. Define the variable first with something like:

NAME_ASTERISK=asterisk

and try running your command again.

Upvotes: 1

Related Questions