In docker container how to run another container command?

Example:
I have a image ubuntu and another image mongodb.

How can I run mongod(mongodb command) or another mongodb image command when I’m running ubuntu image.

  • Docker: Which approach is better? WAR embedded in image or base image + war?
  • Using sudo inside non-priviledged docker container not working
  • How can I link files in Dockerfile?
  • What are the pros and cons of docker data volumes
  • Pycharm docker-compose interpreter not loading libraries
  • QGIS-Server Plugin Process per client (WMS)
  • Dockerfile fails to build
  • Couldn't connect to Docker daemon on ubuntu
  • Why isn't my server restarting / code updating using Docker + Nodejs?
  • fuser returns Cannot Permission denied
  • Docker fails at first run after install. Error Post http://… permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?
  • node-babel works very slow in Docker
  • One Solution collect form web for “In docker container how to run another container command?”

    • Any image will generate one or more containers.
    • Every container is isolated of others.

    If you can run MongoD inside a Ubuntu based container you need to install MongoDB inside your Ubuntu based container.

    But, if you need connect on mondodb to create a user, change settings of your mongod instance, you don’t need a second container, on mongodb container you can execute commands to perform that.

    On mongodb documentation at docker hub, the example about mondodb security talks about it, the example explain how to connect your shell to container, and show how execute docker exec -it [mongodbContainerName|mongodbContainerId] mongo admin to get access to administration of mongodb using console.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.