Docker run not working it says requires at least 1 argument - docker

I'm learning docker, and trying to run the existing images. The first command is working fine
command 1: docker run --name static-site -e AUTHOR="Mathi1" -d -P dockersamples/static-site
But the below command is throwing error
Command 2: docker run --name mvcdotnet -e AUTHOR="Mathi2" -d -p valkyrion/mvcdotnet
Error:
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container

According to docker help run:
…
-p, --publish list Publish a container's port(s) to the host
-P, --publish-all Publish all exposed ports to random ports
…
Command 1 uses -P (short form of --publish-all) and after that the image name. -P has no arguments.
Command 2 uses -p (short form of --publish list). -p expects an argument and I think docker mistakes the image name as the argument for -p (and expects an image name after that).

Related

"docker run" requires at least 1 argument

I'm trying to run this Docker command related to GoPhish
$ docker run -d --restart always -p 8080:8080 -p 8443:8443 --name web_server -v ${HOME}/Docker/Gophish/apache:/opt/bitnami/apache2/htdocs/bitnami/apache:latest
I also tried to use docker container run but it's not working.
but it's showing this issue :
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container

How to use list in "docker's run -e options"?

I downloaded my spring boot project from git on Amazon Linux2 OS and made it a docker image.
Then, I tried to use the "docker run" command to run the docker container with this image.
At this time, there are values in the form of an array among the environmental variables I need, and other "docker run options" worked well, but there was a problem with the values in this form of an array.
// Command 1
docker run -itd --name example_container -e DDL_AUTO={update,create,validate} -p 80:8080 example_image
In command 1's case, docker: invalid reference format: repository name must be lowercase. error occured.
// Command 2 (put space between update, create, validate)
docker run -itd --name example_container -e DDL_AUTO={update, create, validate} -p 80:8080 example_image
In command 2's case, docker: invalid reference format. error occured.
Is there a way to put list optionally in this command format?
You need to put quotes around the environment variable value, since it contains characters the shell would otherwise interpret. Try:
docker run -itd --name example_container -e DDL_AUTO="{update,create,validate}" -p 80:8080 example_image

docker run - autokill container already in use?

I was following this guide on customizing MySQL databases in Docker, and ran this command multiple times after making tweaks to the mounted sql files:
docker run -d -p 3306:3306 --name my-mysql -v /Users/pneedham/dev/docker-testing/sql-scripts:/docker-entrypoint-initdb.d/ -e MYSQL_ROOT_PASSWORD=supersecret -e MYSQL_DATABASE=company mysql
On all subsequent executions of that command, I would see an error like this:
docker: Error response from daemon: Conflict. The container name "/my-mysql" is already in use by container "9dc103de93b7ad0166bb359645c12d49e0aa4a3f2330b5980e455cec24843663". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
What I'd like to know is whether that docker run command can be modified to auto-kill the previous container (if it exists)? Or if there is a different command that has the same desired result.
If I were to create a shell script to do that for me, I'd first run docker ps -aqf "name=mysql" and if there is any output, use that resulting container ID by running docker rm -f $containerID. And then run the original command.
docker run command has a --rm arguments that deletes the container after the run is completed. see the docs . So, just change your command to
docker run --rm -d -p 3306:3306 --name my-mysql -v /Users/pneedham/dev/docker-testing/sql-scripts:/docker-entrypoint-initdb.d/ -e MYSQL_ROOT_PASSWORD=supersecret -e MYSQL_DATABASE=company mysql

Docker volume not showing running linux container on Windows 10

I am running Docker for Windows v19.03.12. I am running a linux container from Windows 10. I am sharing my entire c:\ drive with Docker (see image). I am trying to testing a container locally and need to pass a credentials file to the container.
When I run the following command:
docker run --rm -p 9215:80 -p 44371:443 --name test -t createshipment:latest -v c:/temp:/data
When I explore the container I do not see a /data folder at all (see image).
I am not sure what else to try to share a folder when testing docker locally.
The command docker run expects the image name as the last argument, before any arguments to the image's entrypoint. In the OP's post, the image name precedes the -v ... argument, so -v ... is actually passed to the image's entrypoint.
docker run --rm -p 9215:80 -p 44371:443 --name test -t \
-v c:/temp:/data createshipment:latest
For the sake of completeness, here are the relevant excerpts from the documentation for the command-line options used here:
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
...
--name string Assign a name to the container
-p, --publish list Publish a container's port(s) to the host
--rm Automatically remove the container when it exits
-t, --tty Allocate a pseudo-TTY
-v, --volume list Bind mount a volume

Error message when creating docker container

I'm trying to create a new docker container using the following command:
docker run -d -it --name compsci -v /c/Users/garre/Documents/CPSC_Courses:/homechapmanfse/computing-resources:cs_base
However, it gives me this error message:
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
How would I fix this?
You have to provide the name of the image that you want to run. This is currently missing in your command.
For example, if I were to run mysql, I would execute this:
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
See the last argument, mysql? That is the name of the image.
Think that you it has build image in your machine. You must inform name of image run.
docker run image-name
This command --name is necessary only you specific name for your container. And the -it command must be entered only when entering the executed container.
docker run -d -it -v
/c/Users/garre/Documents/CPSC_Courses:/homechapmanfse/computing-resources:cs_base
--name 'the name you want to give' 'official name of the image'

Resources