Skip to content

Common commands to know

Course: Actionable Docker - chapter 5

  1. docker run
  2. docker ps
  3. docker kill

Let’s say you wan’t to run MongoDB locally https://hub.docker.com/_/mongo

docker run mongo

You will notice you can’t open it in MongoDB Compass .

The reason is that you haven’t added a port mapping

docker run -p 27017:27017 mongo

Adding -d will ensure it starts in the background

docker run -d -p 27017:27017 mongo
docker ps

This will show you all the containers you are running.

docker kill <container_id>

Will stop the container that you are running

In the end, this is the flow of commands -