Error message when creating docker container - docker

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'

Related

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

How to name a container with docker run

How is possible to assign a name to a container while using docker run with interactive mode?
For example, running this command
docker run -d -it docker_image_already_created sh
when checking with docker ps the name is autogenerated. How can the container name be passed?
Provide the --name option:
docker run -d --name your_name -it docker_image_already_created sh

Docker run not working it says requires at least 1 argument

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).

How to find/access /var/log/jasmin inside container

I have created by container with docker with the name jasmin_01 using the command
docker run -d -p 1401:1401 -p 2775:2775 -p 8990:8990 --name jasmin_01 jookies/jasmin:latest
Now, i am trying to access log files located in /var/log/jasmin inside the container by running
docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_01 jookies/jasmin:latest
and i am getting the error
Error response from daemon: Conflict. The container name "/jasmin_01" is already in use by container "6bc05cf61a03b74f2b18d05378048e201e3f6ded768ddaf3f2660c39f9d76888". You have to remove (or rename) that container to be able to reuse that name.
How do i solve this please ?
It conflict cause container name jasmin_01 is already in use. You can check it by docker ps -a. For resolve this problem is:
docker stop jasmin_01
docker rm $(docker ps -a -q)
docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_01 jookies/jasmin:latest
Or easiest way is change you new container name
docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_02 jookies/jasmin:latest
The error is quite indicative of the issue: you are trying to start a new container with the same name (jasmin01). Add a unique name, stop the existing container, or remove the --name so that Docker would create a unique name automatically.
docker run --name foo runs a new container named foo
So, if you try to do it twice, you'll indeed get a duplicate name error, as you see
You probably want docker exec:
$ docker help exec
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
e.g. docker exec jasmine_01 cat /var/log/jasmine/jasmine.log

Why doesn't the docker volume in Windows Server show up when I run this command?

I have a folder setup on the host machine at c:\testvol.
The docker image does not have a folder at c:\testvol.
When I run:
docker run --rm -d --name {name} {imagename} --v c:\testvol:c:\testvol
Why doesn't the volume show up on the container?
It appears in the docker command you need to specify the image name as the last parameter unless you want to pass arguments to be processed by the docker file.
Also, --v should be -v or --volume as --v is not recognized by the docker command.
The command you want is:
docker run --rm -d --name {name} --volume c:\testvol:c:\testvol {imagename}

Resources