Container commands
Now let’s dive deeper into some of the more complicated, but important, commands and command invocations that you may run into when working with Docker.
docker run
Let’s look at a more complex invocation of the docker run
command we used earlier:
docker run --rm --name mywebcontainer -p 80:80 -v /tmp:/usr/share/nginx/html:ro -d nginx
--rm
: Clean up (remove) this container when it exits.--name mywebcontainer
: Give this container a friendly name –mywebcontainer
.-p 80:80
: Map port80
of the host to port80
in the container. The left port number is on the “outside” (the environment running the container), and the right port number represents the “inside” (container) port. For example,-p 4000:80
will map the container’s port80
tolocalhost:4000
.-v /tmp:/usr/share/nginx/html:ro
: Mount a volume – the host environment’s/tmp
directory will be mounted into...