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?

6 Answers 6

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 &

1
  • I think it must be a back slash \ instead of forward slash /
    – umer
    Dec 19, 2022 at 22:05
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
1
  • 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 May 25, 2019 at 22:37
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.

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

1
  • 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. Jul 23, 2021 at 9:02
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]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.