- Download the latest MongoDB Docker image:
docker pull mongo:3.4.4
- Check that the image exists:
docker images
- Start a container:
docker run -d -v /data/db:/data/db --name mymongo mongo:3.4.4
- Check if the container is running successfully:
docker ps
- Let's connect to our mongo server using the mongo client from the container:
docker exec -it mymongo mongo
- Stop the mongo instance and with host mode networking:
docker run -d -v /data/db:/data/db --name mymongo --net=host mongo:3.4.4 --bind_ip 127.0.0.1 --port 27000
- Connect to the new instance using mongo shell:
docker exec -it mymongo mongo localhost:27000