Sat 08 September 2018
When you are likely to run a container on your own machine, you need two steps.
- Find the image repository and a proper tag.
docker runto set container runtime parameters and then start.
We'd like to run a RabbitMQ on your local machine. First, we choose an image from the official repository. E.g. we choose
rabbitmq:management-alpine. So we got the basic command:
$ docker run rabbitmq:management-alpine
To add port forwarding to the container, we need to specify the
$ docker run \ -p 5672:5672 \ -p 15672:15672 \ rabbitmq:management-alpine
It replace our host port
15672 with the container's.
After that, we'd like to give a reasonable name to the container and ask the container auto start after my docker daemon is restarted. So I need to add command
$ docker run \ -p 5672:5672 \ -p 15672:15672 \ --name dev-rabbitmq \ --restart always \ -d \ rabbitmq:management-alpine
And don't forget the
-d if you don't want to attach the container STDIN/STDOUT.