如何以反斜杠运行命令?

时间:2018-12-05 09:08:50

标签: docker command-line cmd strapi

我正在使用Windows,并且想使用strapi image运行docker。

我执行了以下命令:docker pull strapi/strapi

然后我要执行此命令(以cmd为单位):

docker run -e APP_NAME=strapi-app \
           -e DATABASE_CLIENT=mongo \
           -e DATABASE_HOST=strapi-mongo \
           -e DATABASE_PORT=27017 \
           -e DATABASE_NAME=strapi \
           -v `pwd`/strapi-app:/usr/src/api/strapi-app \
           --link strapi-mongo:mongo \
           -p 1337:1337 \
           --name strapi -d strapi/strapi

但是我应该如何执行呢?我从cmd收到此错误:

docker run -e APP_NAME=strapi-app \                                                
docker: invalid reference format.                                                  
See 'docker run --help'.                                                           

-e DATABASE_CLIENT=mongo \                                                         
'-e' is not recognized as an internal or external command,                         
operable program or batch file.                                                    

-e DATABASE_HOST=strapi-mongo \                                                    
'-e' is not recognized as an internal or external command,                         
operable program or batch file.                                                    

-e DATABASE_PORT=27017 \                                                           
'-e' is not recognized as an internal or external command,                         
operable program or batch file.                                                    

-e DATABASE_NAME=strapi \                                                          
'-e' is not recognized as an internal or external command,                         
operable program or batch file.                                                    

-v `pwd`/strapi-app:/usr/src/api/strapi-app \                                      
'-v' is not recognized as an internal or external command,                         
operable program or batch file.                                                    

--link strapi-mongo:mongo \                                                        
'--link' is not recognized as an internal or external command,                     
operable program or batch file.                                                    

-p 1337:1337 \                                                                     
'-p' is not recognized as an internal or external command,                         
operable program or batch file.                                                    

--name strapi -d strapi/strapi                                                     
'--name' is not recognized as an internal or external command,                     
operable program or batch file.                                                    

如果我将其作为一行运行:

docker run -e APP_NAME=strapi-app DATABASE_CLIENT=mongo DATABASE_HOST=strapi-mongo DATABASE_PORT=27017 DATABASE_NAME=strapi -v `pwd`/strapi-app:/usr/src/api/strapi-app --link strapi-mongo:mongo -p 1337:1337 --name strapi -d strapi/strapi

我遇到错误:

docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.

1 个答案:

答案 0 :(得分:0)

您可以按照以下提到的格式运行命令:

docker run -e APP_NAME=strapi-app -e DATABASE_CLIENT=mongo -e DATABASE_HOST=strapi-mongo -e DATABASE_PORT=27017 -e DATABASE_NAME=strapi -v `pwd`/strapi-app:/usr/src/api/strapi-app --link strapi-mongo:mongo -p 1337:1337 --name strapi -d strapi/strapi