15

I'm trying to create a container using a volume that I have already created, but my console shows the error

docker container run" requires at least 1 argument

This is the command I'm trying to run:

docker container run --name db -v volume-dados-do-banco:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypass

I have also tried this one, wih more arguments, but the same error persists:

docker container run -d --name db -p 3306:3306 -e 'ACCEPT_EULA=Y' -e MYSQL_ROOT_PASSWORD=Mypass -v volume-dados-do-banco:/var/lib/mysql

Any thoughts on the reason why this is happening?

Pedro Coelho
  • 1,411
  • 3
  • 18
  • 31

6 Answers6

7

Problem is not with docker, you just didn't specify which image to run. Your command should include Docker image as per documentation.

docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

Example would be:

docker run -d --name db -v volume-dados-do-banco:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypass mysql:latest
3

i just had the same problem with psql my password simply contained & and i needed to escape it with / before &

Patrik Radics
  • 43
  • 1
  • 5
0

try the below command.. it seems a syntax error on your command..

docker container run -d --name db -v volume-dados-do-banco:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypass
Krunal Barot
  • 914
  • 6
  • 17
  • ok. can you please run just from normal volume rather then the sql thing.. docker container run -d --name db -v volume-dados-do-banco:/var/lib/mysql – Krunal Barot May 25 '19 at 22:37
0

I just restarted docker and ran:

docker run --name torgmysqldb --volumes-from volume-dados-banco-mysql -e MYSQL_ROOT_PASSWORD=Mypass -p 3307:3306 mysql

I found out a known issue about this: https://github.com/docker/for-win/issues/2722

danronmoon
  • 3,814
  • 5
  • 34
  • 56
Pedro Coelho
  • 1,411
  • 3
  • 18
  • 31
  • 2
    This known issue is not the problem you had, in your case it is just a misuse of docker run command. Restarting docker is not what helped there, adding image name (`mysql`) at the end did the trick. – Nemanja Ranković Jul 23 '21 at 09:02
0

i have the same problem when i use this:

docker run  -d -p 3306:3306 -v /Volumes/wd4black/mysql -e MYSQL_ROOT_PASSWORD=root mysql

but when i try below, the problem is disappear:

docker run --name my-s -d -p 3306:3306 -v /Volumes/wd4black/mysql -e MYSQL_ROOT_PASSWORD=root mysql

so i think the --name is key, but the doc didn/t write it.

defend orca
  • 617
  • 7
  • 17
0

After you have extracted the image from the Docker repository, you can move on to deploying the new Container with the following code snippet:

sudo docker run --name=[container_name] -d [image_tag_name]