We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Multiple Containers

Running a single container? That's easy. Realtm engineers control entire fleets of containers. Remember, Docker containers are very lightweight. It's normal to run many containers on a single host machine.

Remember, each container is its own isolated environment and process. Even if we start 10 containers from the same image, the image is just the definition of the container (the code and starting environment). Each container is a separate instance of that image.

Assignment

  1. docker run -d -p 8965:80 docker/getting-started
    docker run -d -p 8966:80 docker/getting-started
    docker run -d -p 8967:80 docker/getting-started
    docker run -d -p 8968:80 docker/getting-started
    docker run -d -p 8969:80 docker/getting-started
    

    We use port 80 within each container because that's the port that the application is binding to inside the container. It's being forwarded to the different ports we specify on the host (our) machine.

    We have to use different host ports for different containers because two processes can't bind to the same port on the same operating system.

  2. Keep in mind, even though they all serve the same page, each is served from its own container!

  3. docker ps
    

Run and submit the CLI tests.

When you're done running the tests, make sure to stop the containers.