Reputation: 86057
Can anyone clarify the syntax in this command:
$ docker run -d -P --name web -v /src/webapp:/webapp training/webapp python app.py
I can see that:
Host directory: /src/webapp
Container: /webapp
but what is training/webapp
? Is that the image? If so, why is there a /
?
And is everything after that (i.e. python app.py
) the command that you want to run in the container?
=====
And to clarify with this command:
$ docker run -d -P --name web -v /webapp training/webapp python app.py
How does it work if you ONLY specify -v /webapp
- is that equivalent to /webapp:/webapp
?
Upvotes: 1
Views: 923
Reputation: 15762
Yes, training/webapp
is image name. Dockerhub accept name this way only.
training
is username and webapp
is image name.
if you don't use dockerhub(this is image repository from docker pull image by default) and build image locally then you can give any name.
python app.py : command that will execute when docker up
--name web : this will be name of container
-v /src/webapp:/webapp : this will create volume webapp and mount on /src/webapp
--publish-all, -P : Publish all exposed ports to random ports
For more help see docker run Documentation.
Upvotes: 0
Reputation: 1545
You can find the documentation for docker run
here
The basic structure looks like this:
$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
-d
let's you run your docker container in detached mode, so you won't see the console output-P
publish all exposed ports to the host interfaces--name
the name of your container-v
the volume you mount host/path:container/path
, where in your case /src/webapp
is on your local machine and /webapp
is inside your containertraining/webapp is the username and image name for the docker image. I have linked the image's location on DockerHub for you
python app.py
are the command (python) and the argument run when the container starts (app.py)
Upvotes: 1