Generally speaking, a container should only run one service. In this case, it seems strange to install new software into a container and then commit it
You can create a base image, and everything else is built on this base image
Then, docker-compose and dockerfile essentially allow you to easily manage containers and images (multiple builds of the same dockerfile will be cached as images), so you can write more on your basic image dockerfile, each dockerfile only installs one service you need to use
The screenshot is my docker-compose.yml. When running, it is very clear that there is one service and one container
If it is still troublesome to use
-p
to map the port when running, you can write it in the DockerfileYou can write the run command as a shell file, and then execute this file directly. No need to write every time.
Maybe your usage is not very correct
Generally speaking, a container should only run one service. In this case, it seems strange to install new software into a container and then commit it
You can create a base image, and everything else is built on this base image
Then, docker-compose and dockerfile essentially allow you to easily manage containers and images (multiple builds of the same dockerfile will be cached as images), so you can write more on your basic image dockerfile, each dockerfile only installs one service you need to use
The screenshot is my docker-compose.yml. When running, it is very clear that there is one service and one container