“docker container run” requires at least 1 argument

邮差的信 提交于 2020-03-23 14:09:26

问题


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?


回答1:


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



回答2:


I just restarted docker and runned:

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




回答3:


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



回答4:


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.



来源:https://stackoverflow.com/questions/56308424/docker-container-run-requires-at-least-1-argument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!