In this tutorial, you will learn to manage multiple containers on Docker platform. Start up 3 container application and clean it all up by removing all the containers in the end. Use docker container ls command to ensure everything is correct before and after cleanup.
1. Start mysql container
docker container run -d -p 3306:3306 --name db -e
MYSQL_RANDOM_ROOT_PASSWORD=yes mysql
The above command starts mysql container with the name db and a random password. Use the docker container logs command to find the random password in logs. The -e option is used to pass in environment variable MYSQL_RANDOM_ROOT_PASSWORD as yes.
2. Start apache httpd container
docker container run -d --name webserver -p 8080:80 httpd
This command start the httpd container port forwarded from 80 to host port 8080.
3. Start nginx container
docker container run -d --name proxy -p 80:80 nginx
This command runs the nginx server container on port 80.
4. List all containers
docker container ls
This should display all three mysql, nginx and httpd newly created containers.
5. Remove all containers
First stop all three containers:docker container stop proxy webserver db
Then remove all three containers:docker container rm proxy webserver db
At this point you have successfully completed the whole tutorial.