Meaning of docker command

It seems a simple question but it’s really not clear what the meaning is of this command:

 docker run -d -p 5000:5000 --restart=always --name registry \
      -v `pwd`/certs:/certs \
      -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
      -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
      registry:2

The -v pwd/certs:/certs \is not clear at all.
Could someone give an explanation

That part of the command would mount the folder $pwd/certs on the host as /certs inside the running container. You can check this by typing this after running the command you have in your question.
docker exec $(docker ps -ql) ls /certs

You should see the contents of the $pwd/certs in the containers /certs path. If you add / modify / remove files from the host’s $pwd/certs, it will automatically be reflected in the containers /certs folder. This is very useful in a development setting, like if you want to see changes immediately reflected (or deployed) in the container’s environment.

Hope that clarifies.

1 Like