Home >Operation and Maintenance >Docker >How docker starts image
Method 1: Execute docker run command to start
For example:
docker run -it --env-file ./run/hrms.env -v /opt/hrms/hrms/hrms:/opt/hrms/hrms -p 10.142.8.12:8083:8080 55
Parameter introduction:
–env-file means to load environment variables from a file. The file format is key=value, one variable per line.
-v means to mount the file on the host into the image. The colon in front of it means the host file path. The latter represents the image file path, and the absolute path
-p represents mapping the 8080 port in the image to the 8083 port on the host. 10.142.8.12 represents the host ip
Method 2: docker-compose startup
docker-compose is one of the three swordsmen of docker. It is a plug-in used to specifically start the image. It can be installed through pip install docker-compose
.
You can create a new folder with the following directory structure as the startup folder of the image:
Write the docker-compose.yml file:
Startup:
Switch to the directory where docker-compose.yml is located and execute the following command to start the image.
docker-compose up
Recommended related tutorials: docker tutorial
The above is the detailed content of How docker starts image. For more information, please follow other related articles on the PHP Chinese website!